]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/dcmemory.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMemoryDC
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
11 A memory device context provides a means to draw graphics onto a bitmap.
12 When drawing in to a mono-bitmap, using @c wxWHITE, @c wxWHITE_PEN and
13 @c wxWHITE_BRUSH will draw the background colour (i.e. 0) whereas all other
14 colours will draw the foreground colour (i.e. 1).
16 A bitmap must be selected into the new memory DC before it may be used for
17 anything. Typical usage is as follows:
22 temp_dc.SelectObject(test_bitmap);
24 // We can now draw into the memory DC...
25 // Copy from this DC to another DC.
26 old_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT, temp_dc, 0, 0);
29 Note that the memory DC must be deleted (or the bitmap selected out of it)
30 before a bitmap can be reselected into another memory DC.
32 And, before performing any other operations on the bitmap data, the bitmap
33 must be selected out of the memory DC:
36 temp_dc.SelectObject(wxNullBitmap);
39 This happens automatically when wxMemoryDC object goes out of scope.
46 class wxMemoryDC
: public wxDC
50 Constructs a new memory device context.
52 Use the wxDC::IsOk() member to test whether the constructor was
53 successful in creating a usable device context. Don't forget to select
54 a bitmap into the DC before drawing on it.
59 Constructs a new memory device context having the same characteristics
60 as the given existing device context.
62 This constructor creates a memory device context @e compatible with @a
63 dc in wxMSW, the argument is ignored in the other ports. If @a dc is
64 @NULL, a device context compatible with the screen is created, just as
65 with the default constructor.
70 Constructs a new memory device context and calls SelectObject() with
73 Use the wxDC::IsOk() member to test whether the constructor was
74 successful in creating a usable device context.
76 wxMemoryDC(wxBitmap
& bitmap
);
79 Works exactly like SelectObjectAsSource() but this is the function you
80 should use when you select a bitmap because you want to modify it, e.g.
83 Using SelectObjectAsSource() when modifying the bitmap may incur some
84 problems related to wxBitmap being a reference counted object (see
85 @ref overview_refcount).
87 Before using the updated bitmap data, make sure to select it out of
88 context first either by selecting ::wxNullBitmap into the device
89 context or destroying the device context entirely.
91 If the bitmap is already selected in this device context, nothing is
92 done. If it is selected in another context, the function asserts and
93 drawing on the bitmap won't work correctly.
95 @see wxDC::DrawBitmap()
97 void SelectObject(wxBitmap
& bitmap
);
100 Selects the given bitmap into the device context, to use as the memory
101 bitmap. Selecting the bitmap into a memory DC allows you to draw into
102 the DC (and therefore the bitmap) and also to use wxDC::Blit() to copy
103 the bitmap to a window. For this purpose, you may find wxDC::DrawIcon()
104 easier to use instead.
106 If the argument is ::wxNullBitmap (or some other uninitialised wxBitmap)
107 the current bitmap is selected out of the device context, and the
108 original bitmap restored, allowing the current bitmap to be destroyed
111 void SelectObjectAsSource(const wxBitmap
& bitmap
);