Contents Up Previous Next

wxMemoryDC is-a wxCanvasDC

A memory device context is used for drawing into, or copying from, a bitmap. See also the wxBitmap object.

wxMemoryDC create
wxMemoryDC select-object


wxMemoryDC create

void ( create)

Create a memory device context using the current display depth. No slots need to be initialized.


wxMemoryDC select-object

bool ( select-object wxBitmap bitmap)

Makes this device context the drawing surface for the given bitmap (see wxBitmap). Deleting the memory device context disassociates the bitmap, freeing it to be used with another memory device context. To draw a bitmap on a device context that supports bitmap drawing (i.e. not a Metafile or PostScript device context), using code like the following:

  ;;; Utility function for drawing a bitmap
  (deffunction draw-bitmap (?dc ?bitmap ?x ?y)
   (bind ?mem-dc (make-instance (gensym*) of wxMemoryDC))
   (send ?mem-dc select-object ?bitmap)
   ; Blit the memory device context onto the destination device context
   (send ?dc blit ?x ?y (send ?bitmap get-width) (send ?bitmap get-height)
     ?mem-dc 0.0 0.0)
   (send ?mem-dc delete)
  )
If bitmap is nil, the existing bitmap (if any) will be selected out of the device context. This might be necessary if you wish to delete the bitmap before deleting the device context (for example, for reusing the same device context for different bitmaps).