[plt-scheme] programmatically saving 2htdp/image images? (quasi-patch included)
The 2htdp/image library is awesome. I'd like to use it to generate web page images for test case success/failure, e.g.:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen shot 2010-02-06 at 10.41.43 AM.png
Type: image/png
Size: 17387 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100206/dbf10beb/attachment.png>
-------------- next part --------------
However, I couldn't figure out how to save these things as files without using a right-click.
I wrote this function:
(define (image->file/png image filename)
(let* ([bitmap (make-object bitmap% (image-width image) (image-height image))]
[dc (new bitmap-dc% [bitmap bitmap])])
(render-image image dc 0 0)
(send bitmap save-file filename 'png)))
...and it appears to work. It appears to me that this might be useful to add something like this to mrlib/image-core, if it's not already there. Perhaps I just overlooked it?
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100206/dbf10beb/attachment.p7s>