Contents Up Previous Next

Memory device context

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

memory-dc-create
memory-dc-select-object


memory-dc-create

long ( memory-dc-create)

Create a memory device context and returns its ID.


memory-dc-select-object

long ( memory-dc-select-object long id long bitmap-id)

Makes this device context the drawing surface for the given bitmap (see Bitmap). 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 (memory-dc-create))
   (memory-dc-select-object ?mem-dc ?bitmap)
   ; Blit the memory device context onto the destination device context
   (dc-blit ?dc ?x ?y (bitmap-get-width ?bitmap) (bitmap-get-height ?bitmap)
     ?mem-dc 0.0 0.0)
   (memory-dc-delete ?mem-dc)
  )
If bitmap-id is zero, 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).