[racket] How do you convert an image made with 2htdp/image to a bitmap% object?
FWIW, you should use make-bitmap, not the make-object variant (well, unless
you pass different arguments, but make-bitmap is better).
You could also use the file/convertible and maybe we should add a short
function there that would convert to a bitmap directly (altho I'm not sure
if that introduces unwanted dependencies).
Robby
On Fri, Dec 13, 2013 at 10:25 PM, Daniel Prager
<daniel.a.prager at gmail.com>wrote:
> Maybe one for the standard library?
>
> (define (image->bitmap image)
> (let* ([width (image-width image)]
> [height (image-height image)]
> [bm (make-object bitmap% width height)]
> [dc (make-object bitmap-dc% bm)])
> (send dc clear)
> (send image draw dc 0 0 0 0 width height 0 0 #f)
> bm))
>
> Dan
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131213/33f8c399/attachment.html>