[plt-scheme] duplicate of a bitmap

From: David Richards (vottamusic at verizon.net)
Date: Thu Aug 24 16:48:19 EDT 2006

What is the simplest way to make a duplicate of a bitmap?

Currently I do something like this (which seems overly complicated):

(let* ((_bitmap-dc (new bitmap-dc% (bitmap _bitmap)))
                  (_width  (send _bitmap get-width))
                  (_height (send _bitmap get-height))
                  (_pixels (make-bytes (* 4 _width _height)))
                  (_copy (make-object bitmap% _width _height #f)))
             (send _bitmap-dc get-argb-pixels 0 0 _width _height _pixels 
             (send _bitmap-dc set-bitmap _copy)
             (send _bitmap-dc set-argb-pixels 0 0 _width _height _pixels 
             (send _bitmap-dc set-bitmap #f) ; 'release' the bitmap

- dr

Posted on the users mailing list.