*********** wx.MemoryDC *********** Inheritance diagram for `wx.MemoryDC`: | .. inheritance-diagram:: wx.MemoryDC | Description =========== A memory device context provides a means to draw graphics onto a bitmap. When drawing in to a mono-bitmap, using ``wx.WHITE``, ``wx.WHITE_PEN`` and ``wx.WHITE_BRUSH`` will draw the background colour (i.e. 0) whereas all other colours will draw the foreground colour (i.e. 1). .. seealso:: `wx.Bitmap `_, `wx.DC `_ Derived From ^^^^^^^^^^^^^ * `wx.DC `_ * `wx.Object `_ Known Subclasses ^^^^^^^^^^^^^^^^ `wx.BufferedDC `_, `wx.BufferedPaintDC `_ Remarks ^^^^^^^ A bitmap must be selected into the new memory DC before it may be used for anything. Typical usage is as follows:: # Create a memory DC temp_dc = wx.MemoryDC() temp_dc.SelectObject(test_bitmap) # We can now draw into the memory DC... DrawSomething(temp_dc) # Copy from this DC to another DC. old_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT, temp_dc, 0, 0) temp_dc.SelectObject(wx.NullBitmap) .. note:: Note that the memory DC **must** be deleted (or the bitmap selected out of it) before a bitmap can be reselected into another memory DC. Methods Summary ^^^^^^^^^^^^^^^ * `__init__ <#__init__>`_ * `SelectObject <#SelectObject>`_ * `SelectObjectAsSource <#SelectObjectAsSource>`_ Class API ========= Methods ^^^^^^^ .. method:: __init__(bitmap=wx.NullBitmap) Constructs a new memory device context. Use the `Ok` member to test whether the constructor was successful in creating a usable device context. If a bitmap is not given to this constructor then don't forget to select a bitmap into the DC before drawing on it. **Parameters:** * `bitmap` (`wx.Bitmap `_) | **Returns:** `wx.MemoryDC `_ -------- .. method:: SelectObject(bitmap) Works exactly like `SelectObjectAsSource <#SelectObjectAsSource>`_ but this is the function you should use when you select a bitmap because you want to modify it, e.g. drawing on this DC. Be careful to use this function and not `SelectObjectAsSource <#SelectObjectAsSource>`_ when you want to modify the bitmap you are selecting otherwise you may incurr in some problems related to `wx.Bitmap` being a reference counted object. **Parameters:** * `bitmap` (`wx.Bitmap `_) .. seealso:: `wx.DC.DrawBitmap `_ -------- .. method:: SelectObjectAsSource(bitmap) Selects the given bitmap into the device context, to use as the memory bitmap. Selecting the bitmap into a memory DC allows you to draw into the DC (and therefore the bitmap) and also to use `wx.DC.Blit `_ to copy the bitmap to a window. For this purpose, you may find `wx.DC.DrawIcon `_ easier to use instead. If the argument is `wx.NullBitmap` (or some other uninitialised `wx.Bitmap`) the current bitmap is selected out of the device context, and the original bitmap restored, allowing the current bitmap to be destroyed safely. **Parameters:** * `bitmap` (`wx.Bitmap `_) .. seealso:: `SelectObject <#SelectObject>`_