]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: bitmap.h | |
698d17c3 | 3 | // Purpose: interface of wxBitmap* classes |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
8024723d FM |
9 | |
10 | /** | |
11 | In wxBitmap and wxBitmapHandler context this value means: "use the screen depth". | |
12 | */ | |
13 | #define wxBITMAP_SCREEN_DEPTH (-1) | |
14 | ||
23324ae1 FM |
15 | /** |
16 | @class wxBitmapHandler | |
17 | @wxheader{bitmap.h} | |
7c913512 | 18 | |
698d17c3 FM |
19 | This is the base class for implementing bitmap file loading/saving, and |
20 | bitmap creation from data. | |
23324ae1 | 21 | It is used within wxBitmap and is not normally seen by the application. |
7c913512 | 22 | |
23324ae1 | 23 | If you wish to extend the capabilities of wxBitmap, derive a class from |
698d17c3 | 24 | wxBitmapHandler and add the handler using wxBitmap::AddHandler in your |
23324ae1 | 25 | application initialisation. |
7c913512 | 26 | |
23324ae1 | 27 | @library{wxcore} |
698d17c3 | 28 | @category{misc} |
7c913512 | 29 | |
698d17c3 | 30 | @see @ref overview_bitmap, wxBitmap, wxIcon, wxCursor |
23324ae1 FM |
31 | */ |
32 | class wxBitmapHandler : public wxObject | |
33 | { | |
34 | public: | |
35 | /** | |
698d17c3 FM |
36 | Default constructor. |
37 | ||
38 | In your own default constructor, initialise the members m_name, | |
39 | m_extension and m_type. | |
23324ae1 FM |
40 | */ |
41 | wxBitmapHandler(); | |
42 | ||
43 | /** | |
44 | Destroys the wxBitmapHandler object. | |
45 | */ | |
46 | ~wxBitmapHandler(); | |
47 | ||
48 | /** | |
698d17c3 FM |
49 | Creates a bitmap from the given data, which can be of arbitrary type. |
50 | The wxBitmap object @a bitmap is manipulated by this function. | |
51 | ||
7c913512 | 52 | @param bitmap |
4cc4bfaf | 53 | The wxBitmap object. |
7c913512 | 54 | @param width |
4cc4bfaf | 55 | The width of the bitmap in pixels. |
7c913512 | 56 | @param height |
4cc4bfaf | 57 | The height of the bitmap in pixels. |
7c913512 | 58 | @param depth |
8024723d FM |
59 | The depth of the bitmap in pixels. |
60 | If this is ::wxBITMAP_SCREEN_DEPTH, the screen depth is used. | |
7c913512 | 61 | @param data |
4cc4bfaf | 62 | Data whose type depends on the value of type. |
7c913512 | 63 | @param type |
698d17c3 | 64 | A bitmap type identifier - see ::wxBitmapType for a list |
4cc4bfaf | 65 | of possible values. |
698d17c3 | 66 | |
23324ae1 FM |
67 | @returns @true if the call succeeded, @false otherwise (the default). |
68 | */ | |
8024723d FM |
69 | virtual bool Create(wxBitmap* bitmap, const void* data, wxBitmapType type, |
70 | int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); | |
23324ae1 FM |
71 | |
72 | /** | |
73 | Gets the file extension associated with this handler. | |
74 | */ | |
8024723d | 75 | const wxString& GetExtension() const; |
23324ae1 FM |
76 | |
77 | /** | |
78 | Gets the name of this handler. | |
79 | */ | |
8024723d | 80 | const wxString& GetName() const; |
23324ae1 FM |
81 | |
82 | /** | |
83 | Gets the bitmap type associated with this handler. | |
84 | */ | |
8024723d | 85 | wxBitmapType GetType() const; |
23324ae1 FM |
86 | |
87 | /** | |
698d17c3 FM |
88 | Loads a bitmap from a file or resource, putting the resulting data into |
89 | @a bitmap. | |
90 | ||
7c913512 | 91 | @param bitmap |
4cc4bfaf | 92 | The bitmap object which is to be affected by this operation. |
7c913512 | 93 | @param name |
4cc4bfaf FM |
94 | Either a filename or a Windows resource name. |
95 | The meaning of name is determined by the type parameter. | |
7c913512 | 96 | @param type |
8024723d | 97 | See ::wxBitmapType for values this can take. |
698d17c3 | 98 | |
23324ae1 | 99 | @returns @true if the operation succeeded, @false otherwise. |
698d17c3 | 100 | |
4cc4bfaf | 101 | @see wxBitmap::LoadFile, wxBitmap::SaveFile, SaveFile() |
23324ae1 | 102 | */ |
8024723d | 103 | bool LoadFile(wxBitmap* bitmap, const wxString& name, wxBitmapType type); |
23324ae1 FM |
104 | |
105 | /** | |
106 | Saves a bitmap in the named file. | |
698d17c3 | 107 | |
7c913512 | 108 | @param bitmap |
4cc4bfaf | 109 | The bitmap object which is to be affected by this operation. |
7c913512 | 110 | @param name |
4cc4bfaf | 111 | A filename. The meaning of name is determined by the type parameter. |
7c913512 | 112 | @param type |
8024723d | 113 | See ::wxBitmapType for values this can take. |
7c913512 | 114 | @param palette |
4cc4bfaf | 115 | An optional palette used for saving the bitmap. |
698d17c3 | 116 | |
23324ae1 | 117 | @returns @true if the operation succeeded, @false otherwise. |
698d17c3 | 118 | |
4cc4bfaf | 119 | @see wxBitmap::LoadFile, wxBitmap::SaveFile, LoadFile() |
23324ae1 | 120 | */ |
8024723d | 121 | bool SaveFile(wxBitmap* bitmap, const wxString& name, wxBitmapType type, |
4cc4bfaf | 122 | wxPalette* palette = NULL); |
23324ae1 FM |
123 | |
124 | /** | |
125 | Sets the handler extension. | |
698d17c3 | 126 | |
7c913512 | 127 | @param extension |
4cc4bfaf | 128 | Handler extension. |
23324ae1 FM |
129 | */ |
130 | void SetExtension(const wxString& extension); | |
131 | ||
132 | /** | |
133 | Sets the handler name. | |
698d17c3 | 134 | |
7c913512 | 135 | @param name |
4cc4bfaf | 136 | Handler name. |
23324ae1 FM |
137 | */ |
138 | void SetName(const wxString& name); | |
139 | ||
140 | /** | |
141 | Sets the handler type. | |
698d17c3 | 142 | |
698d17c3 | 143 | @param type |
4cc4bfaf | 144 | Handler type. |
23324ae1 | 145 | */ |
8024723d | 146 | void SetType(wxBitmapType type); |
23324ae1 FM |
147 | }; |
148 | ||
149 | ||
150 | /** | |
151 | @class wxBitmap | |
152 | @wxheader{bitmap.h} | |
7c913512 | 153 | |
23324ae1 FM |
154 | This class encapsulates the concept of a platform-dependent bitmap, |
155 | either monochrome or colour or colour with alpha channel support. | |
7c913512 | 156 | |
698d17c3 | 157 | @note |
8024723d FM |
158 | Many wxBitmap functions take a @e type parameter, which is a value of the |
159 | ::wxBitmapType enumeration. | |
698d17c3 FM |
160 | The validity of those values depends however on the platform where your program |
161 | is running and from the wxWidgets configuration. | |
162 | If all possible wxWidgets settings are used, the Windows platform supports BMP file, | |
163 | BMP resource, XPM data, and XPM. | |
164 | Under wxGTK, the available formats are BMP file, XPM data, XPM file, and PNG file. | |
165 | Under wxMotif, the available formats are XBM data, XBM file, XPM data, XPM file. | |
166 | In addition, wxBitmap can load and save all formats that wxImage; see wxImage for | |
167 | more info. Of course, you must have wxImage handlers loaded. | |
168 | ||
23324ae1 FM |
169 | @library{wxcore} |
170 | @category{gdi} | |
7c913512 | 171 | |
23324ae1 | 172 | @stdobjects |
698d17c3 | 173 | ::wxNullBitmap |
7c913512 | 174 | |
698d17c3 FM |
175 | @see @ref overview_bitmap, @ref overview_bitmap_supportedformats, |
176 | wxDC::Blit, wxIcon, wxCursor, wxBitmap, wxMemoryDC | |
23324ae1 FM |
177 | */ |
178 | class wxBitmap : public wxGDIObject | |
179 | { | |
180 | public: | |
23324ae1 | 181 | /** |
698d17c3 FM |
182 | Default constructor. |
183 | ||
184 | Constructs a bitmap object with no data; an assignment or another member | |
185 | function such as Create() or LoadFile() must be called subsequently. | |
186 | */ | |
187 | wxBitmap(); | |
188 | ||
189 | /** | |
190 | Copy constructor, uses @ref overview_refcount "reference counting". | |
191 | To make a real copy, you can use: | |
192 | ||
193 | @code | |
194 | wxBitmap newBitmap = oldBitmap.GetSubBitmap( | |
195 | wxRect(0, 0, oldBitmap.GetWidth(), oldBitmap.GetHeight())); | |
196 | @endcode | |
197 | */ | |
198 | wxBitmap(const wxBitmap& bitmap); | |
199 | ||
8024723d FM |
200 | |
201 | /* | |
698d17c3 FM |
202 | Creates a bitmap from the given @a data which is interpreted in |
203 | platform-dependent manner. | |
204 | ||
205 | @param data | |
206 | Specifies the bitmap data in a platform-dependent format. | |
207 | @param type | |
208 | May be one of the ::wxBitmapType values and indicates which type of | |
209 | bitmap does @a data contains. See the note in the class | |
210 | detailed description. | |
211 | @param width | |
212 | Specifies the width of the bitmap. | |
213 | @param height | |
214 | Specifies the height of the bitmap. | |
215 | @param depth | |
216 | Specifies the depth of the bitmap. | |
217 | If this is omitted, the display depth of the screen is used. | |
8024723d | 218 | wxBitmap(const void* data, int type, int width, int height, int depth = -1); |
698d17c3 | 219 | |
698d17c3 | 220 | |
8024723d FM |
221 | NOTE: this ctor is not implemented by all port, is somewhat useless |
222 | without further description of the "data" supported formats and | |
223 | uses 'int type' instead of wxBitmapType, so don't document it. | |
698d17c3 | 224 | */ |
698d17c3 FM |
225 | |
226 | /** | |
227 | Creates a bitmap from the given array @a bits. | |
228 | You should only use this function for monochrome bitmaps (depth 1) in | |
229 | portable programs: in this case the bits parameter should contain an XBM image. | |
230 | ||
231 | For other bit depths, the behaviour is platform dependent: under Windows, | |
232 | the data is passed without any changes to the underlying CreateBitmap() API. | |
8024723d FM |
233 | Under other platforms, only monochrome bitmaps may be created using this |
234 | constructor and wxImage should be used for creating colour bitmaps from | |
235 | static data. | |
698d17c3 | 236 | |
7c913512 | 237 | @param bits |
4cc4bfaf | 238 | Specifies an array of pixel values. |
7c913512 | 239 | @param width |
4cc4bfaf | 240 | Specifies the width of the bitmap. |
7c913512 | 241 | @param height |
4cc4bfaf | 242 | Specifies the height of the bitmap. |
7c913512 | 243 | @param depth |
698d17c3 | 244 | Specifies the depth of the bitmap. |
8024723d | 245 | If this is omitted, then a value of 1 (monochrome bitmap) is used. |
698d17c3 FM |
246 | */ |
247 | wxBitmap(const char bits[], int width, int height, int depth = 1); | |
248 | ||
249 | /** | |
8024723d FM |
250 | Creates a new bitmap. A depth of ::wxBITMAP_SCREEN_DEPTH indicates the |
251 | depth of the current screen or visual. | |
252 | Some platforms only support 1 for monochrome and ::wxBITMAP_SCREEN_DEPTH for | |
698d17c3 FM |
253 | the current colour setting. |
254 | ||
255 | A depth of 32 including an alpha channel is supported under MSW, Mac and GTK+. | |
256 | */ | |
8024723d | 257 | wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); |
698d17c3 FM |
258 | |
259 | /** | |
260 | Creates a bitmap from XPM data. | |
261 | */ | |
262 | wxBitmap(const char* const* bits); | |
263 | ||
264 | /** | |
265 | Loads a bitmap from a file or resource. | |
266 | ||
7c913512 | 267 | @param name |
698d17c3 FM |
268 | This can refer to a resource name or a filename under MS Windows and X. |
269 | Its meaning is determined by the @a type parameter. | |
7c913512 | 270 | @param type |
698d17c3 FM |
271 | May be one of the ::wxBitmapType values and indicates which type of |
272 | bitmap should be loaded. See the note in the class detailed description. | |
273 | ||
4cc4bfaf | 274 | @see LoadFile() |
23324ae1 | 275 | */ |
8024723d | 276 | wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_XPM); |
698d17c3 FM |
277 | |
278 | /** | |
8024723d FM |
279 | Creates this bitmap object from the given image. |
280 | This has to be done to actually display an image as you cannot draw an | |
281 | image directly on a window. | |
698d17c3 FM |
282 | |
283 | The resulting bitmap will use the provided colour depth (or that of the | |
8024723d FM |
284 | current system if depth is ::wxBITMAP_SCREEN_DEPTH) which entails that a |
285 | colour reduction may take place. | |
698d17c3 FM |
286 | |
287 | When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube | |
288 | created on program start-up to look up colors. This ensures a very fast conversion, | |
289 | but the image quality won't be perfect (and could be better for photo images using | |
290 | more sophisticated dithering algorithms). | |
291 | ||
292 | On Windows, if there is a palette present (set with SetPalette), it will be | |
293 | used when creating the wxBitmap (most useful in 8-bit display mode). | |
294 | On other platforms, the palette is currently ignored. | |
295 | ||
296 | @param img | |
297 | Platform-independent wxImage object. | |
298 | @param depth | |
299 | Specifies the depth of the bitmap. | |
300 | If this is omitted, the display depth of the screen is used. | |
301 | */ | |
8024723d | 302 | wxBitmap(const wxImage& img, int depth = wxBITMAP_SCREEN_DEPTH); |
23324ae1 FM |
303 | |
304 | /** | |
305 | Destructor. | |
698d17c3 FM |
306 | See @ref overview_refcount_destruct for more info. |
307 | ||
23324ae1 FM |
308 | If the application omits to delete the bitmap explicitly, the bitmap will be |
309 | destroyed automatically by wxWidgets when the application exits. | |
698d17c3 FM |
310 | |
311 | @warning | |
23324ae1 FM |
312 | Do not delete a bitmap that is selected into a memory device context. |
313 | */ | |
314 | ~wxBitmap(); | |
315 | ||
316 | /** | |
317 | Adds a handler to the end of the static list of format handlers. | |
698d17c3 | 318 | |
7c913512 | 319 | @param handler |
4cc4bfaf FM |
320 | A new bitmap format handler object. There is usually only one instance |
321 | of a given handler class in an application session. | |
698d17c3 | 322 | |
4cc4bfaf | 323 | @see wxBitmapHandler |
23324ae1 FM |
324 | */ |
325 | static void AddHandler(wxBitmapHandler* handler); | |
326 | ||
327 | /** | |
328 | Deletes all bitmap handlers. | |
23324ae1 FM |
329 | This function is called by wxWidgets on exit. |
330 | */ | |
331 | static void CleanUpHandlers(); | |
332 | ||
333 | /** | |
334 | Creates an image from a platform-dependent bitmap. This preserves | |
335 | mask information so that bitmaps and images can be converted back | |
336 | and forth without loss in that respect. | |
337 | */ | |
338 | wxImage ConvertToImage(); | |
339 | ||
340 | /** | |
341 | Creates the bitmap from an icon. | |
342 | */ | |
343 | bool CopyFromIcon(const wxIcon& icon); | |
344 | ||
698d17c3 FM |
345 | /** |
346 | Creates a fresh bitmap. | |
347 | If the final argument is omitted, the display depth of the screen is used. | |
348 | ||
349 | This overload works on all platforms. | |
350 | */ | |
8024723d | 351 | virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH); |
698d17c3 | 352 | |
8024723d | 353 | /* |
23324ae1 | 354 | Creates a bitmap from the given data, which can be of arbitrary type. |
698d17c3 FM |
355 | |
356 | @param data | |
357 | Data whose type depends on the value of type. | |
358 | @param type | |
359 | A bitmap type identifier; see ::wxBitmapType for the list of values. | |
360 | See the note in the class detailed description for more info. | |
7c913512 | 361 | @param width |
4cc4bfaf | 362 | The width of the bitmap in pixels. |
7c913512 | 363 | @param height |
4cc4bfaf | 364 | The height of the bitmap in pixels. |
7c913512 | 365 | @param depth |
4cc4bfaf | 366 | The depth of the bitmap in pixels. If this is -1, the screen depth is used. |
698d17c3 | 367 | |
23324ae1 | 368 | @returns @true if the call succeeded, @false otherwise. |
698d17c3 FM |
369 | |
370 | This overload depends on the @a type of data. | |
698d17c3 | 371 | |
7c913512 | 372 | virtual bool Create(const void* data, int type, int width, |
698d17c3 | 373 | int height, int depth = -1); |
23324ae1 | 374 | |
8024723d FM |
375 | NOTE: leave this undoc for the same reason of the relative ctor. |
376 | */ | |
377 | ||
23324ae1 | 378 | /** |
698d17c3 FM |
379 | Finds the handler with the given @a name. |
380 | ||
381 | @returns A pointer to the handler if found, @NULL otherwise. | |
382 | */ | |
383 | static wxBitmapHandler* FindHandler(const wxString& name); | |
384 | ||
385 | /** | |
386 | Finds the handler associated with the given @a extension and @a type. | |
387 | ||
7c913512 | 388 | @param extension |
698d17c3 | 389 | The file extension, such as "bmp" (without the dot). |
7c913512 | 390 | @param bitmapType |
698d17c3 FM |
391 | The bitmap type managed by the handler, see ::wxBitmapType. |
392 | ||
23324ae1 | 393 | @returns A pointer to the handler if found, @NULL otherwise. |
23324ae1 | 394 | */ |
7c913512 FM |
395 | static wxBitmapHandler* FindHandler(const wxString& extension, |
396 | wxBitmapType bitmapType); | |
698d17c3 FM |
397 | |
398 | /** | |
399 | Finds the handler associated with the given bitmap type. | |
400 | ||
401 | @param bitmapType | |
402 | The bitmap type managed by the handler, see ::wxBitmapType. | |
403 | ||
404 | @returns A pointer to the handler if found, @NULL otherwise. | |
405 | ||
406 | @see wxBitmapHandler | |
407 | */ | |
408 | ||
7c913512 | 409 | static wxBitmapHandler* FindHandler(wxBitmapType bitmapType); |
23324ae1 FM |
410 | |
411 | /** | |
8024723d FM |
412 | Gets the colour depth of the bitmap. |
413 | A value of 1 indicates a monochrome bitmap. | |
23324ae1 | 414 | */ |
328f5751 | 415 | int GetDepth() const; |
23324ae1 FM |
416 | |
417 | /** | |
418 | Returns the static list of bitmap format handlers. | |
698d17c3 | 419 | |
4cc4bfaf | 420 | @see wxBitmapHandler |
23324ae1 FM |
421 | */ |
422 | static wxList GetHandlers(); | |
423 | ||
424 | /** | |
425 | Gets the height of the bitmap in pixels. | |
426 | */ | |
328f5751 | 427 | int GetHeight() const; |
23324ae1 FM |
428 | |
429 | /** | |
430 | Gets the associated mask (if any) which may have been loaded from a file | |
431 | or set for the bitmap. | |
698d17c3 | 432 | |
4cc4bfaf | 433 | @see SetMask(), wxMask |
23324ae1 | 434 | */ |
328f5751 | 435 | wxMask* GetMask() const; |
23324ae1 FM |
436 | |
437 | /** | |
438 | Gets the associated palette (if any) which may have been loaded from a file | |
439 | or set for the bitmap. | |
698d17c3 | 440 | |
4cc4bfaf | 441 | @see wxPalette |
23324ae1 | 442 | */ |
328f5751 | 443 | wxPalette* GetPalette() const; |
23324ae1 FM |
444 | |
445 | /** | |
446 | Returns a sub bitmap of the current one as long as the rect belongs entirely to | |
447 | the bitmap. This function preserves bit depth and mask information. | |
448 | */ | |
328f5751 | 449 | wxBitmap GetSubBitmap(const wxRect& rect) const; |
23324ae1 FM |
450 | |
451 | /** | |
452 | Gets the width of the bitmap in pixels. | |
698d17c3 | 453 | |
4cc4bfaf | 454 | @see GetHeight() |
23324ae1 | 455 | */ |
328f5751 | 456 | int GetWidth() const; |
23324ae1 FM |
457 | |
458 | /** | |
459 | Adds the standard bitmap format handlers, which, depending on wxWidgets | |
698d17c3 FM |
460 | configuration, can be handlers for Windows bitmap, Windows bitmap resource, |
461 | and XPM. | |
462 | ||
23324ae1 | 463 | This function is called by wxWidgets on startup. |
698d17c3 | 464 | |
4cc4bfaf | 465 | @see wxBitmapHandler |
23324ae1 FM |
466 | */ |
467 | static void InitStandardHandlers(); | |
468 | ||
469 | /** | |
470 | Adds a handler at the start of the static list of format handlers. | |
698d17c3 | 471 | |
7c913512 | 472 | @param handler |
4cc4bfaf FM |
473 | A new bitmap format handler object. There is usually only one instance |
474 | of a given handler class in an application session. | |
698d17c3 | 475 | |
4cc4bfaf | 476 | @see wxBitmapHandler |
23324ae1 FM |
477 | */ |
478 | static void InsertHandler(wxBitmapHandler* handler); | |
479 | ||
480 | /** | |
481 | Returns @true if bitmap data is present. | |
482 | */ | |
328f5751 | 483 | bool IsOk() const; |
23324ae1 FM |
484 | |
485 | /** | |
486 | Loads a bitmap from a file or resource. | |
698d17c3 | 487 | |
7c913512 | 488 | @param name |
4cc4bfaf | 489 | Either a filename or a Windows resource name. |
698d17c3 | 490 | The meaning of name is determined by the @a type parameter. |
7c913512 | 491 | @param type |
698d17c3 FM |
492 | One of the ::wxBitmapType values; see the note in the class |
493 | detailed description. | |
494 | ||
23324ae1 | 495 | @returns @true if the operation succeeded, @false otherwise. |
698d17c3 | 496 | |
23324ae1 | 497 | @remarks A palette may be associated with the bitmap if one exists |
4cc4bfaf FM |
498 | (especially for colour Windows bitmaps), and if the |
499 | code supports it. You can check if one has been created | |
698d17c3 FM |
500 | by using the GetPalette() member. |
501 | ||
4cc4bfaf | 502 | @see SaveFile() |
23324ae1 FM |
503 | */ |
504 | bool LoadFile(const wxString& name, wxBitmapType type); | |
505 | ||
506 | /** | |
698d17c3 FM |
507 | Finds the handler with the given name, and removes it. |
508 | The handler is not deleted. | |
509 | ||
7c913512 | 510 | @param name |
4cc4bfaf | 511 | The handler name. |
698d17c3 | 512 | |
23324ae1 | 513 | @returns @true if the handler was found and removed, @false otherwise. |
698d17c3 | 514 | |
4cc4bfaf | 515 | @see wxBitmapHandler |
23324ae1 FM |
516 | */ |
517 | static bool RemoveHandler(const wxString& name); | |
518 | ||
519 | /** | |
520 | Saves a bitmap in the named file. | |
698d17c3 | 521 | |
7c913512 | 522 | @param name |
4cc4bfaf | 523 | A filename. The meaning of name is determined by the type parameter. |
7c913512 | 524 | @param type |
698d17c3 FM |
525 | One of the ::wxBitmapType values; see the note in the class |
526 | detailed description. | |
7c913512 | 527 | @param palette |
4cc4bfaf | 528 | An optional palette used for saving the bitmap. |
698d17c3 | 529 | |
23324ae1 | 530 | @returns @true if the operation succeeded, @false otherwise. |
698d17c3 | 531 | |
23324ae1 | 532 | @remarks Depending on how wxWidgets has been configured, not all formats |
4cc4bfaf | 533 | may be available. |
698d17c3 | 534 | |
4cc4bfaf | 535 | @see LoadFile() |
23324ae1 FM |
536 | */ |
537 | bool SaveFile(const wxString& name, wxBitmapType type, | |
8024723d | 538 | const wxPalette* palette = NULL); |
23324ae1 FM |
539 | |
540 | /** | |
541 | Sets the depth member (does not affect the bitmap data). | |
698d17c3 FM |
542 | |
543 | @todo since these functions do not affect the bitmap data, | |
544 | why they exist?? | |
545 | ||
7c913512 | 546 | @param depth |
4cc4bfaf | 547 | Bitmap depth. |
23324ae1 FM |
548 | */ |
549 | void SetDepth(int depth); | |
550 | ||
551 | /** | |
552 | Sets the height member (does not affect the bitmap data). | |
698d17c3 | 553 | |
7c913512 | 554 | @param height |
4cc4bfaf | 555 | Bitmap height in pixels. |
23324ae1 FM |
556 | */ |
557 | void SetHeight(int height); | |
558 | ||
559 | /** | |
560 | Sets the mask for this bitmap. | |
698d17c3 | 561 | |
23324ae1 | 562 | @remarks The bitmap object owns the mask once this has been called. |
698d17c3 | 563 | |
4cc4bfaf | 564 | @see GetMask(), wxMask |
23324ae1 FM |
565 | */ |
566 | void SetMask(wxMask* mask); | |
567 | ||
568 | /** | |
569 | Sets the associated palette. (Not implemented under GTK+). | |
698d17c3 | 570 | |
7c913512 | 571 | @param palette |
4cc4bfaf | 572 | The palette to set. |
698d17c3 | 573 | |
4cc4bfaf | 574 | @see wxPalette |
23324ae1 FM |
575 | */ |
576 | void SetPalette(const wxPalette& palette); | |
577 | ||
578 | /** | |
579 | Sets the width member (does not affect the bitmap data). | |
698d17c3 | 580 | |
7c913512 | 581 | @param width |
4cc4bfaf | 582 | Bitmap width in pixels. |
23324ae1 FM |
583 | */ |
584 | void SetWidth(int width); | |
585 | ||
586 | /** | |
698d17c3 FM |
587 | Assignment operator, using @ref overview_refcount "reference counting". |
588 | ||
7c913512 | 589 | @param bitmap |
4cc4bfaf | 590 | Bitmap to assign. |
23324ae1 FM |
591 | */ |
592 | wxBitmap operator =(const wxBitmap& bitmap); | |
593 | }; | |
594 | ||
e54c96f1 | 595 | /** |
698d17c3 | 596 | An empty wxBitmap object. |
e54c96f1 FM |
597 | */ |
598 | wxBitmap wxNullBitmap; | |
599 | ||
600 | ||
601 | ||
602 | ||
23324ae1 FM |
603 | /** |
604 | @class wxMask | |
605 | @wxheader{bitmap.h} | |
7c913512 | 606 | |
23324ae1 | 607 | This class encapsulates a monochrome mask bitmap, where the masked area is |
698d17c3 FM |
608 | black and the unmasked area is white. |
609 | ||
610 | When associated with a bitmap and drawn in a device context, the unmasked | |
611 | area of the bitmap will be drawn, and the masked area will not be drawn. | |
7c913512 | 612 | |
23324ae1 FM |
613 | @library{wxcore} |
614 | @category{gdi} | |
7c913512 | 615 | |
e54c96f1 | 616 | @see wxBitmap, wxDC::Blit, wxMemoryDC |
23324ae1 FM |
617 | */ |
618 | class wxMask : public wxObject | |
619 | { | |
620 | public: | |
698d17c3 FM |
621 | |
622 | /** | |
623 | Default constructor. | |
624 | */ | |
625 | wxMask(); | |
626 | ||
23324ae1 FM |
627 | /** |
628 | Constructs a mask from a bitmap and a palette index that indicates the | |
698d17c3 FM |
629 | background. |
630 | Not yet implemented for GTK. | |
631 | ||
7c913512 | 632 | @param bitmap |
4cc4bfaf | 633 | A valid bitmap. |
7c913512 | 634 | @param index |
4cc4bfaf | 635 | Index into a palette, specifying the transparency colour. |
23324ae1 | 636 | */ |
7c913512 | 637 | wxMask(const wxBitmap& bitmap, int index); |
698d17c3 FM |
638 | |
639 | /** | |
640 | Constructs a mask from a monochrome bitmap. | |
641 | ||
642 | @beginWxPythonOnly | |
643 | This is the default constructor for wxMask in wxPython. | |
644 | @endWxPythonOnly | |
645 | */ | |
646 | wxMask(const wxBitmap& bitmap); | |
647 | ||
648 | /** | |
649 | Constructs a mask from a bitmap and a colour that indicates the background. | |
650 | ||
651 | @beginWxPythonOnly | |
652 | wxPython has an alternate wxMask constructor matching this form called wxMaskColour. | |
653 | @endWxPythonOnly | |
654 | */ | |
655 | wxMask(const wxBitmap& bitmap, const wxColour& colour); | |
23324ae1 FM |
656 | |
657 | /** | |
658 | Destroys the wxMask object and the underlying bitmap data. | |
659 | */ | |
660 | ~wxMask(); | |
661 | ||
23324ae1 FM |
662 | /** |
663 | Constructs a mask from a bitmap and a palette index that indicates the | |
698d17c3 FM |
664 | background. |
665 | Not yet implemented for GTK. | |
666 | ||
7c913512 | 667 | @param bitmap |
4cc4bfaf | 668 | A valid bitmap. |
7c913512 | 669 | @param index |
4cc4bfaf | 670 | Index into a palette, specifying the transparency colour. |
23324ae1 | 671 | */ |
698d17c3 FM |
672 | bool Create(const wxBitmap& bitmap, int index); |
673 | ||
674 | /** | |
675 | Constructs a mask from a monochrome bitmap. | |
676 | */ | |
23324ae1 | 677 | bool Create(const wxBitmap& bitmap); |
698d17c3 FM |
678 | |
679 | /** | |
680 | Constructs a mask from a bitmap and a colour that indicates the background. | |
681 | */ | |
7c913512 | 682 | bool Create(const wxBitmap& bitmap, const wxColour& colour); |
23324ae1 | 683 | }; |
e54c96f1 | 684 |