bitmap.h 24 KB

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