]>
Commit | Line | Data |
---|---|---|
a660d684 KB |
1 | \section{\class{wxMemoryDC}}\label{wxmemorydc} |
2 | ||
41fbc841 | 3 | A memory device context provides a means to draw graphics onto a bitmap. When |
d17f05af HH |
4 | drawing in to a mono-bitmap, using {\tt wxWHITE}, {\tt wxWHITE\_PEN} and |
5 | {\tt wxWHITE\_BRUSH} | |
41fbc841 RR |
6 | will draw the background colour (i.e. 0) whereas all other colours will draw the |
7 | foreground colour (i.e. 1). | |
a660d684 KB |
8 | |
9 | \wxheading{Derived from} | |
10 | ||
11 | \helpref{wxDC}{wxdc}\\ | |
12 | \helpref{wxObject}{wxobject} | |
13 | ||
954b8ae6 JS |
14 | \wxheading{Include files} |
15 | ||
16 | <wx/dcmemory.h> | |
17 | ||
a660d684 KB |
18 | \wxheading{Remarks} |
19 | ||
20 | A bitmap must be selected into the new memory DC before it may be used | |
21 | for anything. Typical usage is as follows: | |
22 | ||
23 | \begin{verbatim} | |
24 | // Create a memory DC | |
25 | wxMemoryDC temp_dc; | |
26 | temp_dc.SelectObject(test_bitmap); | |
27 | ||
28 | // We can now draw into the memory DC... | |
29 | // Copy from this DC to another DC. | |
30 | old_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT, temp_dc, 0, 0); | |
31 | \end{verbatim} | |
32 | ||
33 | Note that the memory DC {\it must} be deleted (or the bitmap selected out of it) before a bitmap | |
34 | can be reselected into another memory DC. | |
35 | ||
36 | \wxheading{See also} | |
37 | ||
38 | \helpref{wxBitmap}{wxbitmap}, \helpref{wxDC}{wxdc} | |
39 | ||
40 | \latexignore{\rtfignore{\wxheading{Members}}} | |
41 | ||
dcbd177f | 42 | \membersection{wxMemoryDC::wxMemoryDC}\label{wxmemorydcctor} |
a660d684 | 43 | |
fea35690 | 44 | \func{}{wxMemoryDC}{\void} |
a660d684 KB |
45 | |
46 | Constructs a new memory device context. | |
47 | ||
fea35690 VZ |
48 | Use the \helpref{IsOk}{wxdcisok} member to test whether the constructor was successful |
49 | in creating a usable device context. | |
50 | Don't forget to select a bitmap into the DC before drawing on it. | |
51 | ||
52 | \func{}{wxMemoryDC}{\param{wxBitmap\& }{bitmap}} | |
53 | ||
54 | Constructs a new memory device context and calls \helpref{SelectObject}{wxmemorydcselectobject} | |
55 | with the given bitmap. | |
56 | Use the \helpref{IsOk}{wxdcisok} member to test whether the constructor was successful | |
57 | in creating a usable device context. | |
58 | ||
a660d684 | 59 | |
dcbd177f | 60 | \membersection{wxMemoryDC::SelectObject}\label{wxmemorydcselectobject} |
a660d684 | 61 | |
fea35690 VZ |
62 | \func{void}{SelectObject}{\param{wxBitmap\& }{bitmap}} |
63 | ||
64 | Works exactly like \helpref{SelectObjectAsSource}{wxmemorydcselectobjectassource} but | |
65 | this is the function you should use when you select a bitmap because you want to modify | |
66 | it, e.g. drawing on this DC. | |
67 | ||
68 | Be careful to use this function and not \helpref{SelectObjectAsSource}{wxmemorydcselectobjectassource} | |
69 | when you want to modify the bitmap you are selecting otherwise you may incurr in some | |
70 | problems related to wxBitmap being a reference counted object | |
71 | (see \helpref{reference counting overview}{trefcount}). | |
72 | ||
73 | \wxheading{See also} | |
74 | ||
75 | \helpref{wxDC::DrawBitmap}{wxdcdrawbitmap} | |
76 | ||
77 | ||
78 | ||
79 | \membersection{wxMemoryDC::SelectObjectAsSource}\label{wxmemorydcselectobjectassource} | |
80 | ||
81 | \func{void}{SelectObjectAsSource}{\param{const wxBitmap\& }{bitmap}} | |
a660d684 KB |
82 | |
83 | Selects the given bitmap into the device context, to use as the memory | |
84 | bitmap. Selecting the bitmap into a memory DC allows you to draw into | |
fea35690 | 85 | the DC (and therefore the bitmap) and also to use \helpref{wxDC::Blit}{wxdcblit} to copy |
fe604ccd | 86 | the bitmap to a window. For this purpose, you may find \helpref{wxDC::DrawIcon}{wxdcdrawicon}\rtfsp |
a660d684 KB |
87 | easier to use instead. |
88 | ||
fea35690 VZ |
89 | If the argument is wxNullBitmap (or some other uninitialised wxBitmap) the current bitmap is |
90 | selected out of the device context, and the original bitmap restored, allowing the current bitmap to | |
a660d684 KB |
91 | be destroyed safely. |
92 | ||
fea35690 VZ |
93 | \wxheading{See also} |
94 | ||
95 | \helpref{wxMemoryDC::SelectObject}{wxmemorydcselectobject} | |
9b50920f | 96 |