]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/bitmap.h
Applied #15226 with modifications: wxRichTextCtrl: Implement setting properties with...
[wxWidgets.git] / interface / wx / bitmap.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: bitmap.h
698d17c3 3// Purpose: interface of wxBitmap* classes
23324ae1 4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
23324ae1
FM
6/////////////////////////////////////////////////////////////////////////////
7
8024723d
FM
8
9/**
10 In wxBitmap and wxBitmapHandler context this value means: "use the screen depth".
11*/
12#define wxBITMAP_SCREEN_DEPTH (-1)
13
23324ae1
FM
14/**
15 @class wxBitmapHandler
7c913512 16
698d17c3
FM
17 This is the base class for implementing bitmap file loading/saving, and
18 bitmap creation from data.
23324ae1 19 It is used within wxBitmap and is not normally seen by the application.
7c913512 20
23324ae1 21 If you wish to extend the capabilities of wxBitmap, derive a class from
1413ac04 22 wxBitmapHandler and add the handler using wxBitmap::AddHandler() in your
c83d207b 23 application initialization.
7c913512 24
427c415b
FM
25 Note that all wxBitmapHandlers provided by wxWidgets are part of the
26 @ref page_libs_wxcore library.
27 For details about the default handlers, please see the note in the
28 wxBitmap class documentation.
29
23324ae1 30 @library{wxcore}
3c99e2fd 31 @category{gdi}
7c913512 32
698d17c3 33 @see @ref overview_bitmap, wxBitmap, wxIcon, wxCursor
23324ae1
FM
34*/
35class wxBitmapHandler : public wxObject
36{
37public:
38 /**
698d17c3
FM
39 Default constructor.
40
41 In your own default constructor, initialise the members m_name,
42 m_extension and m_type.
23324ae1
FM
43 */
44 wxBitmapHandler();
45
46 /**
47 Destroys the wxBitmapHandler object.
48 */
d2aa927a 49 virtual ~wxBitmapHandler();
23324ae1
FM
50
51 /**
698d17c3
FM
52 Creates a bitmap from the given data, which can be of arbitrary type.
53 The wxBitmap object @a bitmap is manipulated by this function.
54
7c913512 55 @param bitmap
4cc4bfaf 56 The wxBitmap object.
7c913512 57 @param width
4cc4bfaf 58 The width of the bitmap in pixels.
7c913512 59 @param height
4cc4bfaf 60 The height of the bitmap in pixels.
7c913512 61 @param depth
8024723d
FM
62 The depth of the bitmap in pixels.
63 If this is ::wxBITMAP_SCREEN_DEPTH, the screen depth is used.
7c913512 64 @param data
4cc4bfaf 65 Data whose type depends on the value of type.
7c913512 66 @param type
698d17c3 67 A bitmap type identifier - see ::wxBitmapType for a list
4cc4bfaf 68 of possible values.
698d17c3 69
d29a9a8a 70 @return @true if the call succeeded, @false otherwise (the default).
23324ae1 71 */
8024723d 72 virtual bool Create(wxBitmap* bitmap, const void* data, wxBitmapType type,
1413ac04 73 int width, int height, int depth = 1);
23324ae1
FM
74
75 /**
76 Gets the file extension associated with this handler.
77 */
8024723d 78 const wxString& GetExtension() const;
23324ae1
FM
79
80 /**
81 Gets the name of this handler.
82 */
8024723d 83 const wxString& GetName() const;
23324ae1
FM
84
85 /**
86 Gets the bitmap type associated with this handler.
87 */
8024723d 88 wxBitmapType GetType() const;
23324ae1
FM
89
90 /**
698d17c3
FM
91 Loads a bitmap from a file or resource, putting the resulting data into
92 @a bitmap.
93
3939acd2
VZ
94 @note Under MSW, when loading a bitmap from resources (i.e. using @c
95 wxBITMAP_TYPE_BMP_RESOURCE as @a type), the light grey colour is
96 considered to be transparent, for historical reasons. If you want
97 to handle the light grey pixels normally instead, call
98 SetMask(NULL) after loading the bitmap.
99
7c913512 100 @param bitmap
4cc4bfaf 101 The bitmap object which is to be affected by this operation.
7c913512 102 @param name
4cc4bfaf
FM
103 Either a filename or a Windows resource name.
104 The meaning of name is determined by the type parameter.
7c913512 105 @param type
8024723d 106 See ::wxBitmapType for values this can take.
2fd0ada5
FM
107 @param desiredWidth
108 The desired width for the loaded bitmap.
109 @param desiredHeight
110 The desired height for the loaded bitmap.
698d17c3 111
d29a9a8a 112 @return @true if the operation succeeded, @false otherwise.
698d17c3 113
4cc4bfaf 114 @see wxBitmap::LoadFile, wxBitmap::SaveFile, SaveFile()
23324ae1 115 */
1413ac04
FM
116 virtual bool LoadFile(wxBitmap* bitmap, const wxString& name, wxBitmapType type,
117 int desiredWidth, int desiredHeight);
23324ae1
FM
118
119 /**
120 Saves a bitmap in the named file.
698d17c3 121
7c913512 122 @param bitmap
4cc4bfaf 123 The bitmap object which is to be affected by this operation.
7c913512 124 @param name
4cc4bfaf 125 A filename. The meaning of name is determined by the type parameter.
7c913512 126 @param type
8024723d 127 See ::wxBitmapType for values this can take.
7c913512 128 @param palette
4cc4bfaf 129 An optional palette used for saving the bitmap.
698d17c3 130
d29a9a8a 131 @return @true if the operation succeeded, @false otherwise.
698d17c3 132
4cc4bfaf 133 @see wxBitmap::LoadFile, wxBitmap::SaveFile, LoadFile()
23324ae1 134 */
1413ac04 135 virtual bool SaveFile(const wxBitmap* bitmap, const wxString& name, wxBitmapType type,
2fd0ada5 136 const wxPalette* palette = NULL) const;
23324ae1
FM
137
138 /**
139 Sets the handler extension.
698d17c3 140
7c913512 141 @param extension
4cc4bfaf 142 Handler extension.
23324ae1
FM
143 */
144 void SetExtension(const wxString& extension);
145
146 /**
147 Sets the handler name.
698d17c3 148
7c913512 149 @param name
4cc4bfaf 150 Handler name.
23324ae1
FM
151 */
152 void SetName(const wxString& name);
153
154 /**
155 Sets the handler type.
698d17c3 156
698d17c3 157 @param type
4cc4bfaf 158 Handler type.
23324ae1 159 */
8024723d 160 void SetType(wxBitmapType type);
23324ae1
FM
161};
162
163
164/**
165 @class wxBitmap
7c913512 166
23324ae1
FM
167 This class encapsulates the concept of a platform-dependent bitmap,
168 either monochrome or colour or colour with alpha channel support.
cbea3ec6 169
de022e4f
RR
170 If you need direct access the bitmap data instead going through
171 drawing to it using wxMemoryDC you need to use the wxPixelData
172 class (either wxNativePixelData for RGB bitmaps or wxAlphaPixelData
f090e4ef 173 for bitmaps with an additionally alpha channel).
7c913512 174
c83d207b
FM
175 Note that many wxBitmap functions take a @e type parameter, which is a
176 value of the ::wxBitmapType enumeration.
698d17c3
FM
177 The validity of those values depends however on the platform where your program
178 is running and from the wxWidgets configuration.
c83d207b
FM
179 If all possible wxWidgets settings are used:
180 - wxMSW supports BMP and ICO files, BMP and ICO resources;
181 - wxGTK supports XPM files;
182 - wxMac supports PICT resources;
183 - wxX11 supports XPM files, XPM data, XBM data;
184
185 In addition, wxBitmap can load and save all formats that wxImage can; see wxImage
186 for more info. Of course, you must have loaded the wxImage handlers
187 (see ::wxInitAllImageHandlers() and wxImage::AddHandler).
188 Note that all available wxBitmapHandlers for a given wxWidgets port are
189 automatically loaded at startup so you won't need to use wxBitmap::AddHandler.
698d17c3 190
fcd9ed6c
JC
191 More on the difference between wxImage and wxBitmap: wxImage is just a
192 buffer of RGB bytes with an optional buffer for the alpha bytes. It is all
193 generic, platform independent and image file format independent code. It
194 includes generic code for scaling, resizing, clipping, and other manipulations
195 of the image data. OTOH, wxBitmap is intended to be a wrapper of whatever is
196 the native image format that is quickest/easiest to draw to a DC or to be the
197 target of the drawing operations performed on a wxMemoryDC. By splitting the
198 responsibilities between wxImage/wxBitmap like this then it's easier to use
199 generic code shared by all platforms and image types for generic operations and
200 platform specific code where performance or compatibility is needed.
201
23324ae1
FM
202 @library{wxcore}
203 @category{gdi}
7c913512 204
23324ae1 205 @stdobjects
698d17c3 206 ::wxNullBitmap
7c913512 207
698d17c3 208 @see @ref overview_bitmap, @ref overview_bitmap_supportedformats,
de022e4f 209 wxDC::Blit, wxIcon, wxCursor, wxMemoryDC, wxImage, wxPixelData
23324ae1
FM
210*/
211class wxBitmap : public wxGDIObject
212{
213public:
23324ae1 214 /**
698d17c3
FM
215 Default constructor.
216
217 Constructs a bitmap object with no data; an assignment or another member
218 function such as Create() or LoadFile() must be called subsequently.
219 */
220 wxBitmap();
221
222 /**
223 Copy constructor, uses @ref overview_refcount "reference counting".
224 To make a real copy, you can use:
225
226 @code
227 wxBitmap newBitmap = oldBitmap.GetSubBitmap(
228 wxRect(0, 0, oldBitmap.GetWidth(), oldBitmap.GetHeight()));
229 @endcode
230 */
231 wxBitmap(const wxBitmap& bitmap);
232
8024723d
FM
233
234 /*
698d17c3
FM
235 Creates a bitmap from the given @a data which is interpreted in
236 platform-dependent manner.
237
238 @param data
239 Specifies the bitmap data in a platform-dependent format.
240 @param type
241 May be one of the ::wxBitmapType values and indicates which type of
242 bitmap does @a data contains. See the note in the class
243 detailed description.
244 @param width
245 Specifies the width of the bitmap.
246 @param height
247 Specifies the height of the bitmap.
248 @param depth
249 Specifies the depth of the bitmap.
250 If this is omitted, the display depth of the screen is used.
8024723d 251 wxBitmap(const void* data, int type, int width, int height, int depth = -1);
698d17c3 252
698d17c3 253
1413ac04 254 NOTE: this ctor is not implemented by all ports, is somewhat useless
8024723d
FM
255 without further description of the "data" supported formats and
256 uses 'int type' instead of wxBitmapType, so don't document it.
698d17c3 257 */
698d17c3
FM
258
259 /**
260 Creates a bitmap from the given array @a bits.
261 You should only use this function for monochrome bitmaps (depth 1) in
262 portable programs: in this case the bits parameter should contain an XBM image.
263
264 For other bit depths, the behaviour is platform dependent: under Windows,
265 the data is passed without any changes to the underlying CreateBitmap() API.
8024723d
FM
266 Under other platforms, only monochrome bitmaps may be created using this
267 constructor and wxImage should be used for creating colour bitmaps from
268 static data.
698d17c3 269
7c913512 270 @param bits
4cc4bfaf 271 Specifies an array of pixel values.
7c913512 272 @param width
4cc4bfaf 273 Specifies the width of the bitmap.
7c913512 274 @param height
4cc4bfaf 275 Specifies the height of the bitmap.
7c913512 276 @param depth
698d17c3 277 Specifies the depth of the bitmap.
8024723d 278 If this is omitted, then a value of 1 (monochrome bitmap) is used.
1058f652
MB
279
280 @beginWxPerlOnly
281 In wxPerl use Wx::Bitmap->newFromBits(bits, width, height, depth).
282 @endWxPerlOnly
698d17c3 283 */
ab6a33b4 284 wxBitmap(const char bits[], int width, int height, int depth = 1);
698d17c3
FM
285
286 /**
8024723d
FM
287 Creates a new bitmap. A depth of ::wxBITMAP_SCREEN_DEPTH indicates the
288 depth of the current screen or visual.
1413ac04 289
8024723d 290 Some platforms only support 1 for monochrome and ::wxBITMAP_SCREEN_DEPTH for
698d17c3
FM
291 the current colour setting.
292
293 A depth of 32 including an alpha channel is supported under MSW, Mac and GTK+.
294 */
8024723d 295 wxBitmap(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
732d8c74
FM
296
297 /**
298 @overload
299 */
300 wxBitmap(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
698d17c3
FM
301
302 /**
303 Creates a bitmap from XPM data.
1058f652
MB
304
305 @beginWxPerlOnly
306 In wxPerl use Wx::Bitmap->newFromXPM(data).
307 @endWxPerlOnly
698d17c3
FM
308 */
309 wxBitmap(const char* const* bits);
310
311 /**
312 Loads a bitmap from a file or resource.
313
7c913512 314 @param name
698d17c3
FM
315 This can refer to a resource name or a filename under MS Windows and X.
316 Its meaning is determined by the @a type parameter.
7c913512 317 @param type
698d17c3
FM
318 May be one of the ::wxBitmapType values and indicates which type of
319 bitmap should be loaded. See the note in the class detailed description.
cbea3ec6
FM
320 Note that the wxBITMAP_DEFAULT_TYPE constant has different value under
321 different wxWidgets ports. See the bitmap.h header for the value it takes
322 for a specific port.
698d17c3 323
4cc4bfaf 324 @see LoadFile()
23324ae1 325 */
cbea3ec6 326 wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
698d17c3
FM
327
328 /**
8024723d
FM
329 Creates this bitmap object from the given image.
330 This has to be done to actually display an image as you cannot draw an
331 image directly on a window.
698d17c3
FM
332
333 The resulting bitmap will use the provided colour depth (or that of the
8024723d
FM
334 current system if depth is ::wxBITMAP_SCREEN_DEPTH) which entails that a
335 colour reduction may take place.
698d17c3
FM
336
337 When in 8-bit mode (PseudoColour mode), the GTK port will use a color cube
338 created on program start-up to look up colors. This ensures a very fast conversion,
339 but the image quality won't be perfect (and could be better for photo images using
340 more sophisticated dithering algorithms).
341
342 On Windows, if there is a palette present (set with SetPalette), it will be
343 used when creating the wxBitmap (most useful in 8-bit display mode).
344 On other platforms, the palette is currently ignored.
345
346 @param img
347 Platform-independent wxImage object.
348 @param depth
349 Specifies the depth of the bitmap.
350 If this is omitted, the display depth of the screen is used.
351 */
8024723d 352 wxBitmap(const wxImage& img, int depth = wxBITMAP_SCREEN_DEPTH);
23324ae1
FM
353
354 /**
355 Destructor.
698d17c3
FM
356 See @ref overview_refcount_destruct for more info.
357
23324ae1
FM
358 If the application omits to delete the bitmap explicitly, the bitmap will be
359 destroyed automatically by wxWidgets when the application exits.
698d17c3
FM
360
361 @warning
23324ae1
FM
362 Do not delete a bitmap that is selected into a memory device context.
363 */
d2aa927a 364 virtual ~wxBitmap();
23324ae1
FM
365
366 /**
367 Adds a handler to the end of the static list of format handlers.
698d17c3 368
7c913512 369 @param handler
4cc4bfaf
FM
370 A new bitmap format handler object. There is usually only one instance
371 of a given handler class in an application session.
c83d207b
FM
372
373 Note that unlike wxImage::AddHandler, there's no documented list of
374 the wxBitmapHandlers available in wxWidgets.
375 This is because they are platform-specific and most important, they are
376 all automatically loaded at startup.
377
378 If you want to be sure that wxBitmap can load a certain type of image,
379 you'd better use wxImage::AddHandler.
698d17c3 380
4cc4bfaf 381 @see wxBitmapHandler
23324ae1
FM
382 */
383 static void AddHandler(wxBitmapHandler* handler);
384
385 /**
386 Deletes all bitmap handlers.
23324ae1
FM
387 This function is called by wxWidgets on exit.
388 */
389 static void CleanUpHandlers();
390
391 /**
392 Creates an image from a platform-dependent bitmap. This preserves
393 mask information so that bitmaps and images can be converted back
394 and forth without loss in that respect.
395 */
1413ac04 396 virtual wxImage ConvertToImage() const;
23324ae1
FM
397
398 /**
399 Creates the bitmap from an icon.
400 */
1413ac04 401 virtual bool CopyFromIcon(const wxIcon& icon);
23324ae1 402
698d17c3
FM
403 /**
404 Creates a fresh bitmap.
405 If the final argument is omitted, the display depth of the screen is used.
732d8c74
FM
406
407 @return @true if the creation was successful.
698d17c3 408 */
1413ac04 409 virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH);
732d8c74
FM
410
411 /**
412 @overload
413 */
414 virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH);
698d17c3 415
8024723d 416 /*
23324ae1 417 Creates a bitmap from the given data, which can be of arbitrary type.
698d17c3
FM
418
419 @param data
420 Data whose type depends on the value of type.
421 @param type
422 A bitmap type identifier; see ::wxBitmapType for the list of values.
423 See the note in the class detailed description for more info.
7c913512 424 @param width
4cc4bfaf 425 The width of the bitmap in pixels.
7c913512 426 @param height
4cc4bfaf 427 The height of the bitmap in pixels.
7c913512 428 @param depth
4cc4bfaf 429 The depth of the bitmap in pixels. If this is -1, the screen depth is used.
698d17c3 430
d29a9a8a 431 @return @true if the call succeeded, @false otherwise.
698d17c3
FM
432
433 This overload depends on the @a type of data.
698d17c3 434
7c913512 435 virtual bool Create(const void* data, int type, int width,
698d17c3 436 int height, int depth = -1);
23324ae1 437
8024723d
FM
438 NOTE: leave this undoc for the same reason of the relative ctor.
439 */
440
23324ae1 441 /**
698d17c3
FM
442 Finds the handler with the given @a name.
443
d29a9a8a 444 @return A pointer to the handler if found, @NULL otherwise.
698d17c3
FM
445 */
446 static wxBitmapHandler* FindHandler(const wxString& name);
447
448 /**
449 Finds the handler associated with the given @a extension and @a type.
450
7c913512 451 @param extension
698d17c3 452 The file extension, such as "bmp" (without the dot).
7c913512 453 @param bitmapType
698d17c3
FM
454 The bitmap type managed by the handler, see ::wxBitmapType.
455
d29a9a8a 456 @return A pointer to the handler if found, @NULL otherwise.
23324ae1 457 */
7c913512
FM
458 static wxBitmapHandler* FindHandler(const wxString& extension,
459 wxBitmapType bitmapType);
698d17c3
FM
460
461 /**
462 Finds the handler associated with the given bitmap type.
463
464 @param bitmapType
465 The bitmap type managed by the handler, see ::wxBitmapType.
466
d29a9a8a 467 @return A pointer to the handler if found, @NULL otherwise.
698d17c3
FM
468
469 @see wxBitmapHandler
470 */
471
7c913512 472 static wxBitmapHandler* FindHandler(wxBitmapType bitmapType);
23324ae1
FM
473
474 /**
8024723d
FM
475 Gets the colour depth of the bitmap.
476 A value of 1 indicates a monochrome bitmap.
23324ae1 477 */
1413ac04 478 virtual int GetDepth() const;
23324ae1
FM
479
480 /**
481 Returns the static list of bitmap format handlers.
698d17c3 482
4cc4bfaf 483 @see wxBitmapHandler
23324ae1 484 */
382f12e4 485 static wxList& GetHandlers();
23324ae1
FM
486
487 /**
488 Gets the height of the bitmap in pixels.
c74b07ac
FM
489
490 @see GetWidth(), GetSize()
23324ae1 491 */
1413ac04 492 virtual int GetHeight() const;
23324ae1
FM
493
494 /**
495 Gets the associated mask (if any) which may have been loaded from a file
496 or set for the bitmap.
698d17c3 497
4cc4bfaf 498 @see SetMask(), wxMask
23324ae1 499 */
1413ac04 500 virtual wxMask* GetMask() const;
23324ae1
FM
501
502 /**
503 Gets the associated palette (if any) which may have been loaded from a file
504 or set for the bitmap.
698d17c3 505
4cc4bfaf 506 @see wxPalette
23324ae1 507 */
1413ac04 508 virtual wxPalette* GetPalette() const;
23324ae1
FM
509
510 /**
511 Returns a sub bitmap of the current one as long as the rect belongs entirely to
512 the bitmap. This function preserves bit depth and mask information.
513 */
1413ac04 514 virtual wxBitmap GetSubBitmap(const wxRect& rect) const;
23324ae1 515
c74b07ac
FM
516 /**
517 Returns the size of the bitmap in pixels.
518
519 @since 2.9.0
520
521 @see GetHeight(), GetWidth()
522 */
523 wxSize GetSize() const;
524
198c264d
JS
525 /**
526 Returns disabled (dimmed) version of the bitmap.
ac04aa99
VZ
527
528 This method is not available when <code>wxUSE_IMAGE == 0</code>.
529
198c264d
JS
530 @since 2.9.0
531 */
532 wxBitmap ConvertToDisabled(unsigned char brightness = 255) const;
533
23324ae1
FM
534 /**
535 Gets the width of the bitmap in pixels.
698d17c3 536
c74b07ac 537 @see GetHeight(), GetSize()
23324ae1 538 */
1413ac04 539 virtual int GetWidth() const;
23324ae1
FM
540
541 /**
542 Adds the standard bitmap format handlers, which, depending on wxWidgets
698d17c3
FM
543 configuration, can be handlers for Windows bitmap, Windows bitmap resource,
544 and XPM.
545
23324ae1 546 This function is called by wxWidgets on startup.
698d17c3 547
4cc4bfaf 548 @see wxBitmapHandler
23324ae1
FM
549 */
550 static void InitStandardHandlers();
551
552 /**
553 Adds a handler at the start of the static list of format handlers.
698d17c3 554
7c913512 555 @param handler
4cc4bfaf
FM
556 A new bitmap format handler object. There is usually only one instance
557 of a given handler class in an application session.
698d17c3 558
4cc4bfaf 559 @see wxBitmapHandler
23324ae1
FM
560 */
561 static void InsertHandler(wxBitmapHandler* handler);
562
563 /**
564 Returns @true if bitmap data is present.
565 */
0004982c 566 virtual bool IsOk() const;
23324ae1
FM
567
568 /**
569 Loads a bitmap from a file or resource.
698d17c3 570
7c913512 571 @param name
4cc4bfaf 572 Either a filename or a Windows resource name.
698d17c3 573 The meaning of name is determined by the @a type parameter.
7c913512 574 @param type
698d17c3
FM
575 One of the ::wxBitmapType values; see the note in the class
576 detailed description.
cbea3ec6
FM
577 Note that the wxBITMAP_DEFAULT_TYPE constant has different value under
578 different wxWidgets ports. See the bitmap.h header for the value it takes
579 for a specific port.
698d17c3 580
d29a9a8a 581 @return @true if the operation succeeded, @false otherwise.
698d17c3 582
23324ae1 583 @remarks A palette may be associated with the bitmap if one exists
4cc4bfaf
FM
584 (especially for colour Windows bitmaps), and if the
585 code supports it. You can check if one has been created
698d17c3
FM
586 by using the GetPalette() member.
587
4cc4bfaf 588 @see SaveFile()
23324ae1 589 */
cbea3ec6 590 virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE);
23324ae1 591
20e6714a
VZ
592 /**
593 Loads a bitmap from the memory containing image data in PNG format.
594
595 This helper function provides the simplest way to create a wxBitmap
596 from PNG image data. On most platforms, it's simply a wrapper around
597 wxImage loading functions and so requires the PNG image handler to be
598 registered by either calling wxInitAllImageHandlers() which also
599 registers all the other image formats or including the necessary
600 header:
601 @code
602 #include <wx/imagpng.h>
603 @endcode
604 and calling
605 @code
606 wxImage::AddHandler(new wxPNGHandler);
607 @endcode
608 in your application startup code.
609
610 However under OS X this function uses native image loading and so
611 doesn't require wxWidgets PNG support.
612
613 @since 2.9.5
614 */
615 static wxBitmap NewFromPNGData(const void* data, size_t size);
616
23324ae1 617 /**
698d17c3
FM
618 Finds the handler with the given name, and removes it.
619 The handler is not deleted.
620
7c913512 621 @param name
4cc4bfaf 622 The handler name.
698d17c3 623
d29a9a8a 624 @return @true if the handler was found and removed, @false otherwise.
698d17c3 625
4cc4bfaf 626 @see wxBitmapHandler
23324ae1
FM
627 */
628 static bool RemoveHandler(const wxString& name);
629
630 /**
631 Saves a bitmap in the named file.
698d17c3 632
7c913512 633 @param name
4cc4bfaf 634 A filename. The meaning of name is determined by the type parameter.
7c913512 635 @param type
698d17c3
FM
636 One of the ::wxBitmapType values; see the note in the class
637 detailed description.
7c913512 638 @param palette
4cc4bfaf 639 An optional palette used for saving the bitmap.
698d17c3 640
d29a9a8a 641 @return @true if the operation succeeded, @false otherwise.
698d17c3 642
23324ae1 643 @remarks Depending on how wxWidgets has been configured, not all formats
4cc4bfaf 644 may be available.
698d17c3 645
4cc4bfaf 646 @see LoadFile()
23324ae1 647 */
1413ac04
FM
648 virtual bool SaveFile(const wxString& name, wxBitmapType type,
649 const wxPalette* palette = NULL) const;
23324ae1
FM
650
651 /**
652 Sets the depth member (does not affect the bitmap data).
698d17c3
FM
653
654 @todo since these functions do not affect the bitmap data,
655 why they exist??
656
7c913512 657 @param depth
4cc4bfaf 658 Bitmap depth.
23324ae1 659 */
1413ac04 660 virtual void SetDepth(int depth);
23324ae1
FM
661
662 /**
663 Sets the height member (does not affect the bitmap data).
698d17c3 664
7c913512 665 @param height
4cc4bfaf 666 Bitmap height in pixels.
23324ae1 667 */
1413ac04 668 virtual void SetHeight(int height);
23324ae1
FM
669
670 /**
671 Sets the mask for this bitmap.
698d17c3 672
23324ae1 673 @remarks The bitmap object owns the mask once this has been called.
698d17c3 674
4cc4bfaf 675 @see GetMask(), wxMask
23324ae1 676 */
1413ac04 677 virtual void SetMask(wxMask* mask);
23324ae1
FM
678
679 /**
680 Sets the associated palette. (Not implemented under GTK+).
698d17c3 681
7c913512 682 @param palette
4cc4bfaf 683 The palette to set.
698d17c3 684
4cc4bfaf 685 @see wxPalette
23324ae1 686 */
1413ac04 687 virtual void SetPalette(const wxPalette& palette);
23324ae1
FM
688
689 /**
690 Sets the width member (does not affect the bitmap data).
698d17c3 691
7c913512 692 @param width
4cc4bfaf 693 Bitmap width in pixels.
23324ae1 694 */
1413ac04 695 virtual void SetWidth(int width);
23324ae1
FM
696};
697
e54c96f1 698/**
698d17c3 699 An empty wxBitmap object.
e54c96f1
FM
700*/
701wxBitmap wxNullBitmap;
702
703
704
705
23324ae1
FM
706/**
707 @class wxMask
7c913512 708
23324ae1 709 This class encapsulates a monochrome mask bitmap, where the masked area is
698d17c3
FM
710 black and the unmasked area is white.
711
712 When associated with a bitmap and drawn in a device context, the unmasked
713 area of the bitmap will be drawn, and the masked area will not be drawn.
7c913512 714
23324ae1
FM
715 @library{wxcore}
716 @category{gdi}
7c913512 717
e54c96f1 718 @see wxBitmap, wxDC::Blit, wxMemoryDC
23324ae1
FM
719*/
720class wxMask : public wxObject
721{
722public:
698d17c3
FM
723
724 /**
725 Default constructor.
726 */
727 wxMask();
728
23324ae1
FM
729 /**
730 Constructs a mask from a bitmap and a palette index that indicates the
698d17c3
FM
731 background.
732 Not yet implemented for GTK.
733
7c913512 734 @param bitmap
4cc4bfaf 735 A valid bitmap.
7c913512 736 @param index
4cc4bfaf 737 Index into a palette, specifying the transparency colour.
23324ae1 738 */
7c913512 739 wxMask(const wxBitmap& bitmap, int index);
698d17c3
FM
740
741 /**
742 Constructs a mask from a monochrome bitmap.
698d17c3
FM
743 */
744 wxMask(const wxBitmap& bitmap);
745
746 /**
747 Constructs a mask from a bitmap and a colour that indicates the background.
698d17c3
FM
748 */
749 wxMask(const wxBitmap& bitmap, const wxColour& colour);
23324ae1
FM
750
751 /**
752 Destroys the wxMask object and the underlying bitmap data.
753 */
d2aa927a 754 virtual ~wxMask();
23324ae1 755
23324ae1
FM
756 /**
757 Constructs a mask from a bitmap and a palette index that indicates the
698d17c3
FM
758 background.
759 Not yet implemented for GTK.
760
7c913512 761 @param bitmap
4cc4bfaf 762 A valid bitmap.
7c913512 763 @param index
4cc4bfaf 764 Index into a palette, specifying the transparency colour.
23324ae1 765 */
698d17c3
FM
766 bool Create(const wxBitmap& bitmap, int index);
767
768 /**
769 Constructs a mask from a monochrome bitmap.
770 */
23324ae1 771 bool Create(const wxBitmap& bitmap);
698d17c3
FM
772
773 /**
774 Constructs a mask from a bitmap and a colour that indicates the background.
775 */
7c913512 776 bool Create(const wxBitmap& bitmap, const wxColour& colour);
5ca21fe7
PC
777
778 /**
779 Returns the mask as a monochrome bitmap.
780 Currently this method is implemented in wxMSW, wxGTK and wxOSX.
781
782 @since 2.9.5
783 */
784 wxBitmap GetBitmap() const;
23324ae1 785};
e54c96f1 786