Arjun
Arjun

Reputation: 1711

Racket - export Pict to Image File

How would I go about exporting a Racket pict as an image file I can use on a web page?

(any html-capable format or data-uri would do)

Upvotes: 5

Views: 681

Answers (1)

soegaard
soegaard

Reputation: 31145

#lang racket
(require pict)

(define (save-pict the-pict name kind)
  (define bm (pict->bitmap the-pict))
  (send bm save-file name kind))

(save-pict (standard-fish 200 200) "fish.png" 'png)

This saves an image in "fish.png".

enter image description here

Upvotes: 9

Related Questions