[racket] How do you convert an image made with 2htdp/image to a bitmap% object?

From: Daniel Prager (daniel.a.prager at gmail.com)
Date: Fri Dec 13 23:25:43 EST 2013

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)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131214/44bee03e/attachment.html>

Posted on the users mailing list.