[plt-scheme] Save image file from canvas
I can't work it out either, but oyu may be able to use the following
techique to draw straight to a bitmap-dc which you can save.
- I can't remember where I found this;
#lang scheme/gui
(let
((bitmap (make-object bitmap% 255 255))
(dc (make-object bitmap-dc%))
(red-amount 150)
(image-file "test.jpg"))
(send dc set-bitmap bitmap)
;; do some drawing
(do ((x 0 (+ x 1)))
((>= x 255))
(do ((y 0 (+ y 1)))
((>= y 255))
(send dc set-pixel x y
(make-object color% x y 50)
))
)
;;
(when (file-exists? image-file)
(delete-file image-file))
;; this bit saves the canvas
(send bitmap save-file image-file 'jpeg 100)
(display image-file)
(display (current-directory))
)
2009/5/14 Scott Brown <sukottoburaun at yahoo.co.jp>
> I have created a turtle module which draws pictures using
> a canvas% object and the draw-line method of dc from the
> PLT Graphics Toolkit.
> Is there some way to save pictures drawn to canvas% as
> image files?
>
>
> --------------------------------------
> Power up the Internet with Yahoo! Toolbar.
> http://pr.mail.yahoo.co.jp/toolbar/
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
--
--
Stephen De Gabrielle
stephen.degabrielle at acm.org
Telephone +44 (0)20 85670911
Mobile +44 (0)79 85189045
http://www.degabrielle.name/stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090514/35606390/attachment.html>