]>
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 | ||
a7af285d VZ |
18 | \wxheading{Library} |
19 | ||
20 | \helpref{wxCore}{librarieslist} | |
21 | ||
a660d684 KB |
22 | \wxheading{Remarks} |
23 | ||
24 | A bitmap must be selected into the new memory DC before it may be used | |
25 | for anything. Typical usage is as follows: | |
26 | ||
27 | \begin{verbatim} | |
28 | // Create a memory DC | |
29 | wxMemoryDC temp_dc; | |
30 | temp_dc.SelectObject(test_bitmap); | |
31 | ||
32 | // We can now draw into the memory DC... | |
33 | // Copy from this DC to another DC. | |
34 | old_dc.Blit(250, 50, BITMAP_WIDTH, BITMAP_HEIGHT, temp_dc, 0, 0); | |
35 | \end{verbatim} | |
36 | ||
37 | Note that the memory DC {\it must} be deleted (or the bitmap selected out of it) before a bitmap | |
38 | can be reselected into another memory DC. | |
39 | ||
f20f1e94 VZ |
40 | And, before performing any other operations on the bitmap data, the bitmap must |
41 | be selected out of the memory DC: | |
42 | ||
43 | \begin{verbatim} | |
44 | temp_dc.SelectObject(wxNullBitmap) | |
45 | \end{verbatim} | |
46 | ||
47 | (this happens automatically when wxMemoryDC object goes out of scope). | |
48 | ||
49 | ||
a660d684 KB |
50 | \wxheading{See also} |
51 | ||
52 | \helpref{wxBitmap}{wxbitmap}, \helpref{wxDC}{wxdc} | |
53 | ||
54 | \latexignore{\rtfignore{\wxheading{Members}}} | |
55 | ||
dcbd177f | 56 | \membersection{wxMemoryDC::wxMemoryDC}\label{wxmemorydcctor} |
a660d684 | 57 | |
fea35690 | 58 | \func{}{wxMemoryDC}{\void} |
a660d684 KB |
59 | |
60 | Constructs a new memory device context. | |
61 | ||
fea35690 VZ |
62 | Use the \helpref{IsOk}{wxdcisok} member to test whether the constructor was successful |
63 | in creating a usable device context. | |
64 | Don't forget to select a bitmap into the DC before drawing on it. | |
65 | ||
66 | \func{}{wxMemoryDC}{\param{wxBitmap\& }{bitmap}} | |
67 | ||
68 | Constructs a new memory device context and calls \helpref{SelectObject}{wxmemorydcselectobject} | |
69 | with the given bitmap. | |
70 | Use the \helpref{IsOk}{wxdcisok} member to test whether the constructor was successful | |
71 | in creating a usable device context. | |
72 | ||
a660d684 | 73 | |
dcbd177f | 74 | \membersection{wxMemoryDC::SelectObject}\label{wxmemorydcselectobject} |
a660d684 | 75 | |
fea35690 VZ |
76 | \func{void}{SelectObject}{\param{wxBitmap\& }{bitmap}} |
77 | ||
78 | Works exactly like \helpref{SelectObjectAsSource}{wxmemorydcselectobjectassource} but | |
79 | this is the function you should use when you select a bitmap because you want to modify | |
80 | it, e.g. drawing on this DC. | |
81 | ||
f20f1e94 VZ |
82 | Using \helpref{SelectObjectAsSource}{wxmemorydcselectobjectassource} when modifying |
83 | the bitmap may incurr some problems related to wxBitmap being a reference counted object | |
fea35690 VZ |
84 | (see \helpref{reference counting overview}{trefcount}). |
85 | ||
f20f1e94 VZ |
86 | Also, before using the updated bitmap data, make sure to select it out of context first |
87 | (for example by selecting wxNullBitmap into the device context). | |
88 | ||
fea35690 VZ |
89 | \wxheading{See also} |
90 | ||
91 | \helpref{wxDC::DrawBitmap}{wxdcdrawbitmap} | |
92 | ||
93 | ||
94 | ||
95 | \membersection{wxMemoryDC::SelectObjectAsSource}\label{wxmemorydcselectobjectassource} | |
96 | ||
97 | \func{void}{SelectObjectAsSource}{\param{const wxBitmap\& }{bitmap}} | |
a660d684 KB |
98 | |
99 | Selects the given bitmap into the device context, to use as the memory | |
100 | bitmap. Selecting the bitmap into a memory DC allows you to draw into | |
fea35690 | 101 | the DC (and therefore the bitmap) and also to use \helpref{wxDC::Blit}{wxdcblit} to copy |
fe604ccd | 102 | the bitmap to a window. For this purpose, you may find \helpref{wxDC::DrawIcon}{wxdcdrawicon}\rtfsp |
a660d684 KB |
103 | easier to use instead. |
104 | ||
fea35690 VZ |
105 | If the argument is wxNullBitmap (or some other uninitialised wxBitmap) the current bitmap is |
106 | selected out of the device context, and the original bitmap restored, allowing the current bitmap to | |
a660d684 KB |
107 | be destroyed safely. |
108 | ||
fea35690 VZ |
109 | \wxheading{See also} |
110 | ||
111 | \helpref{wxMemoryDC::SelectObject}{wxmemorydcselectobject} | |
9b50920f | 112 |