$szTitle = "wxmemorydc"; include "./_header.inc"; ?>
a memory device context provides a means to draw graphics onto a bitmap. when drawing in to a mono-bitmap, using wxwhite, wxwhite_pen and wxwhite_brush will draw the background colour (i.e. 0) whereas all other colours will draw the foreground colour (i.e. 1).
derived from
include files
<wx/dcmemory.h>
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 wxmemorydc temp_dc; temp_dc.selectobject(test_bitmap); // we can now draw into the memory dc... // copy from this dc to another dc. old_dc.blit(250, 50, bitmap_width, bitmap_height, temp_dc, 0, 0);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.
see also
members
wxmemorydc::wxmemorydc
wxmemorydc::selectobject
wxmemorydc::selectobjectassource
wxmemorydc()
constructs a new memory device context.
use the isok member to test whether the constructor was successful in creating a usable device context. don't forget to select a bitmap into the dc before drawing on it.
wxmemorydc(wxbitmap& bitmap)
constructs a new memory device context and calls selectobject with the given bitmap. use the isok member to test whether the constructor was successful in creating a usable device context.
void selectobject(wxbitmap& bitmap)
works exactly like 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 when you want to modify the bitmap you are selecting otherwise you may incurr in some problems related to wxbitmap being a reference counted object (see reference counting overview).
see also
void selectobjectassource(const wxbitmap& 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 wxdc::blit to copy the bitmap to a window. for this purpose, you may find wxdc::drawicon easier to use instead.
if the argument is wxnullbitmap (or some other uninitialised wxbitmap) the current bitmap is selected out of the device context, and the original bitmap restored, allowing the current bitmap to be destroyed safely.
see also
include "./_footer.inc"; ?>