image.h 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: image.h
  3. // Purpose: interface of wxImageHandler and wxImage
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. Possible values for the image resolution option.
  9. @see wxImage::GetOptionInt().
  10. */
  11. enum wxImageResolution
  12. {
  13. /// Resolution not specified.
  14. wxIMAGE_RESOLUTION_NONE = 0,
  15. /// Resolution specified in inches.
  16. wxIMAGE_RESOLUTION_INCHES = 1,
  17. /// Resolution specified in centimetres.
  18. wxIMAGE_RESOLUTION_CM = 2
  19. };
  20. /**
  21. Image resize algorithm.
  22. This is used with wxImage::Scale() and wxImage::Rescale().
  23. */
  24. enum wxImageResizeQuality
  25. {
  26. /// Simplest and fastest algorithm.
  27. wxIMAGE_QUALITY_NEAREST,
  28. /// Compromise between wxIMAGE_QUALITY_NEAREST and wxIMAGE_QUALITY_BICUBIC.
  29. wxIMAGE_QUALITY_BILINEAR,
  30. /// Highest quality but slowest execution time.
  31. wxIMAGE_QUALITY_BICUBIC,
  32. /**
  33. Use surrounding pixels to calculate an average that will be used for
  34. new pixels. This method is typically used when reducing the size of
  35. an image.
  36. */
  37. wxIMAGE_QUALITY_BOX_AVERAGE,
  38. /**
  39. Default image resizing algorithm used by wxImage::Scale(). Currently
  40. the same as wxIMAGE_QUALITY_NEAREST.
  41. */
  42. wxIMAGE_QUALITY_NORMAL,
  43. /**
  44. Best image resizing algorithm. Since version 2.9.2 this results in
  45. wxIMAGE_QUALITY_BOX_AVERAGE being used when reducing the size of the
  46. image (meaning that both the new width and height will be smaller than
  47. the original size). Otherwise wxIMAGE_QUALITY_BICUBIC is used.
  48. */
  49. wxIMAGE_QUALITY_HIGH
  50. };
  51. /**
  52. Possible values for PNG image type option.
  53. @see wxImage::GetOptionInt().
  54. */
  55. enum wxImagePNGType
  56. {
  57. wxPNG_TYPE_COLOUR = 0, ///< Colour PNG image.
  58. wxPNG_TYPE_GREY = 2, ///< Greyscale PNG image converted from RGB.
  59. wxPNG_TYPE_GREY_RED = 3, ///< Greyscale PNG image using red as grey.
  60. wxPNG_TYPE_PALETTE = 4 ///< Palette encoding.
  61. };
  62. /**
  63. Image option names.
  64. */
  65. #define wxIMAGE_OPTION_QUALITY wxString("quality")
  66. #define wxIMAGE_OPTION_FILENAME wxString("FileName")
  67. #define wxIMAGE_OPTION_RESOLUTION wxString("Resolution")
  68. #define wxIMAGE_OPTION_RESOLUTIONX wxString("ResolutionX")
  69. #define wxIMAGE_OPTION_RESOLUTIONY wxString("ResolutionY")
  70. #define wxIMAGE_OPTION_RESOLUTIONUNIT wxString("ResolutionUnit")
  71. #define wxIMAGE_OPTION_MAX_WIDTH wxString("MaxWidth")
  72. #define wxIMAGE_OPTION_MAX_HEIGHT wxString("MaxHeight")
  73. #define wxIMAGE_OPTION_ORIGINAL_WIDTH wxString("OriginalWidth")
  74. #define wxIMAGE_OPTION_ORIGINAL_HEIGHT wxString("OriginalHeight")
  75. #define wxIMAGE_OPTION_BMP_FORMAT wxString("wxBMP_FORMAT")
  76. #define wxIMAGE_OPTION_CUR_HOTSPOT_X wxString("HotSpotX")
  77. #define wxIMAGE_OPTION_CUR_HOTSPOT_Y wxString("HotSpotY")
  78. #define wxIMAGE_OPTION_GIF_COMMENT wxString("GifComment")
  79. #define wxIMAGE_OPTION_PNG_FORMAT wxString("PngFormat")
  80. #define wxIMAGE_OPTION_PNG_BITDEPTH wxString("PngBitDepth")
  81. #define wxIMAGE_OPTION_PNG_FILTER wxString("PngF")
  82. #define wxIMAGE_OPTION_PNG_COMPRESSION_LEVEL wxString("PngZL")
  83. #define wxIMAGE_OPTION_PNG_COMPRESSION_MEM_LEVEL wxString("PngZM")
  84. #define wxIMAGE_OPTION_PNG_COMPRESSION_STRATEGY wxString("PngZS")
  85. #define wxIMAGE_OPTION_PNG_COMPRESSION_BUFFER_SIZE wxString("PngZB")
  86. #define wxIMAGE_OPTION_TIFF_BITSPERSAMPLE wxString("BitsPerSample")
  87. #define wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL wxString("SamplesPerPixel")
  88. #define wxIMAGE_OPTION_TIFF_COMPRESSION wxString("Compression")
  89. #define wxIMAGE_OPTION_TIFF_PHOTOMETRIC wxString("Photometric")
  90. #define wxIMAGE_OPTION_TIFF_IMAGEDESCRIPTOR wxString("ImageDescriptor")
  91. enum
  92. {
  93. wxBMP_24BPP = 24, // default, do not need to set
  94. //wxBMP_16BPP = 16, // wxQuantize can only do 236 colors?
  95. wxBMP_8BPP = 8, // 8bpp, quantized colors
  96. wxBMP_8BPP_GREY = 9, // 8bpp, rgb averaged to greys
  97. wxBMP_8BPP_GRAY = wxBMP_8BPP_GREY,
  98. wxBMP_8BPP_RED = 10, // 8bpp, red used as greyscale
  99. wxBMP_8BPP_PALETTE = 11, // 8bpp, use the wxImage's palette
  100. wxBMP_4BPP = 4, // 4bpp, quantized colors
  101. wxBMP_1BPP = 1, // 1bpp, quantized "colors"
  102. wxBMP_1BPP_BW = 2 // 1bpp, black & white from red
  103. };
  104. /**
  105. @class wxImageHandler
  106. This is the base class for implementing image file loading/saving, and
  107. image creation from data.
  108. It is used within wxImage and is not normally seen by the application.
  109. If you wish to extend the capabilities of wxImage, derive a class from
  110. wxImageHandler and add the handler using wxImage::AddHandler in your
  111. application initialization.
  112. Note that all wxImageHandlers provided by wxWidgets are part of
  113. the @ref page_libs_wxcore library.
  114. For details about the default handlers, please see the section
  115. @ref image_handlers in the wxImage class documentation.
  116. @section imagehandler_note Note (Legal Issue)
  117. This software is based in part on the work of the Independent JPEG Group.
  118. (Applies when wxWidgets is linked with JPEG support.
  119. wxJPEGHandler uses libjpeg created by IJG.)
  120. @stdobjects
  121. ::wxNullImage
  122. @library{wxcore}
  123. @category{gdi}
  124. @see wxImage, wxInitAllImageHandlers()
  125. */
  126. class wxImageHandler : public wxObject
  127. {
  128. public:
  129. /**
  130. Default constructor.
  131. In your own default constructor, initialise the members
  132. m_name, m_extension and m_type.
  133. */
  134. wxImageHandler();
  135. /**
  136. Destroys the wxImageHandler object.
  137. */
  138. virtual ~wxImageHandler();
  139. /**
  140. Returns @true if this handler supports the image format contained in the
  141. given stream.
  142. This function doesn't modify the current stream position (because it
  143. restores the original position before returning; this however requires the
  144. stream to be seekable; see wxStreamBase::IsSeekable).
  145. */
  146. bool CanRead( wxInputStream& stream );
  147. /**
  148. Returns @true if this handler supports the image format contained in the
  149. file with the given name.
  150. This function doesn't modify the current stream position (because it
  151. restores the original position before returning; this however requires the
  152. stream to be seekable; see wxStreamBase::IsSeekable).
  153. */
  154. bool CanRead( const wxString& filename );
  155. /**
  156. Gets the preferred file extension associated with this handler.
  157. @see GetAltExtensions()
  158. */
  159. const wxString& GetExtension() const;
  160. /**
  161. Returns the other file extensions associated with this handler.
  162. The preferred extension for this handler is returned by GetExtension().
  163. @since 2.9.0
  164. */
  165. const wxArrayString& GetAltExtensions() const;
  166. /**
  167. If the image file contains more than one image and the image handler is capable
  168. of retrieving these individually, this function will return the number of
  169. available images.
  170. @param stream
  171. Opened input stream for reading image data.
  172. This function doesn't modify the current stream position (because it
  173. restores the original position before returning; this however requires the
  174. stream to be seekable; see wxStreamBase::IsSeekable).
  175. @return Number of available images. For most image handlers, this is 1
  176. (exceptions are TIFF and ICO formats as well as animated GIFs
  177. for which this function returns the number of frames in the
  178. animation).
  179. */
  180. virtual int GetImageCount(wxInputStream& stream);
  181. /**
  182. Gets the MIME type associated with this handler.
  183. */
  184. const wxString& GetMimeType() const;
  185. /**
  186. Gets the name of this handler.
  187. */
  188. const wxString& GetName() const;
  189. /**
  190. Gets the image type associated with this handler.
  191. */
  192. wxBitmapType GetType() const;
  193. /**
  194. Loads a image from a stream, putting the resulting data into @a image.
  195. If the image file contains more than one image and the image handler is
  196. capable of retrieving these individually, @a index indicates which image
  197. to read from the stream.
  198. @param image
  199. The image object which is to be affected by this operation.
  200. @param stream
  201. Opened input stream for reading image data.
  202. @param verbose
  203. If set to @true, errors reported by the image handler will produce
  204. wxLogMessages.
  205. @param index
  206. The index of the image in the file (starting from zero).
  207. @return @true if the operation succeeded, @false otherwise.
  208. @see wxImage::LoadFile, wxImage::SaveFile, SaveFile()
  209. */
  210. virtual bool LoadFile(wxImage* image, wxInputStream& stream,
  211. bool verbose = true, int index = -1);
  212. /**
  213. Saves a image in the output stream.
  214. @param image
  215. The image object which is to be affected by this operation.
  216. @param stream
  217. Opened output stream for writing the data.
  218. @param verbose
  219. If set to @true, errors reported by the image handler will produce
  220. wxLogMessages.
  221. @return @true if the operation succeeded, @false otherwise.
  222. @see wxImage::LoadFile, wxImage::SaveFile, LoadFile()
  223. */
  224. virtual bool SaveFile(wxImage* image, wxOutputStream& stream,
  225. bool verbose = true);
  226. /**
  227. Sets the preferred file extension associated with this handler.
  228. @param extension
  229. File extension without leading dot.
  230. @see SetAltExtensions()
  231. */
  232. void SetExtension(const wxString& extension);
  233. /**
  234. Sets the alternative file extensions associated with this handler.
  235. @param extensions
  236. Array of file extensions.
  237. @see SetExtension()
  238. @since 2.9.0
  239. */
  240. void SetAltExtensions(const wxArrayString& extensions);
  241. /**
  242. Sets the handler MIME type.
  243. @param mimetype
  244. Handler MIME type.
  245. */
  246. void SetMimeType(const wxString& mimetype);
  247. /**
  248. Sets the handler name.
  249. @param name
  250. Handler name.
  251. */
  252. void SetName(const wxString& name);
  253. /**
  254. Retrieve the version information about the image library used by this
  255. handler.
  256. This method is not present in wxImageHandler class itself but is
  257. present in a few of the classes deriving from it, currently
  258. wxJPEGHandler, wxPNGHandler and wxTIFFHandler. It returns the
  259. information about the version of the image library being used for the
  260. corresponding handler implementation.
  261. @since 2.9.2
  262. */
  263. static wxVersionInfo GetLibraryVersionInfo();
  264. protected:
  265. /**
  266. Called to get the number of images available in a multi-image file
  267. type, if supported.
  268. NOTE: this function is allowed to change the current stream position
  269. since GetImageCount() will take care of restoring it later
  270. */
  271. virtual int DoGetImageCount( wxInputStream& stream );
  272. /**
  273. Called to test if this handler can read an image from the given stream.
  274. NOTE: this function is allowed to change the current stream position
  275. since CallDoCanRead() will take care of restoring it later
  276. */
  277. virtual bool DoCanRead( wxInputStream& stream ) = 0;
  278. };
  279. /**
  280. Constant used to indicate the alpha value conventionally defined as
  281. the complete transparency.
  282. */
  283. const unsigned char wxIMAGE_ALPHA_TRANSPARENT = 0;
  284. /**
  285. Constant used to indicate the alpha value conventionally defined as
  286. the complete opacity.
  287. */
  288. const unsigned char wxIMAGE_ALPHA_OPAQUE = 0xff;
  289. const unsigned char wxIMAGE_ALPHA_THRESHOLD = 0x80;
  290. /**
  291. @class wxImage
  292. This class encapsulates a platform-independent image.
  293. An image can be created from data, or using wxBitmap::ConvertToImage.
  294. An image can be loaded from a file in a variety of formats, and is extensible
  295. to new formats via image format handlers. Functions are available to set and
  296. get image bits, so it can be used for basic image manipulation.
  297. A wxImage cannot (currently) be drawn directly to a wxDC.
  298. Instead, a platform-specific wxBitmap object must be created from it using
  299. the wxBitmap::wxBitmap(wxImage,int depth) constructor.
  300. This bitmap can then be drawn in a device context, using wxDC::DrawBitmap.
  301. More on the difference between wxImage and wxBitmap: wxImage is just a
  302. buffer of RGB bytes with an optional buffer for the alpha bytes. It is all
  303. generic, platform independent and image file format independent code. It
  304. includes generic code for scaling, resizing, clipping, and other manipulations
  305. of the image data. OTOH, wxBitmap is intended to be a wrapper of whatever is
  306. the native image format that is quickest/easiest to draw to a DC or to be the
  307. target of the drawing operations performed on a wxMemoryDC. By splitting the
  308. responsibilities between wxImage/wxBitmap like this then it's easier to use
  309. generic code shared by all platforms and image types for generic operations and
  310. platform specific code where performance or compatibility is needed.
  311. One colour value of the image may be used as a mask colour which will lead to
  312. the automatic creation of a wxMask object associated to the bitmap object.
  313. @section image_alpha Alpha channel support
  314. Starting from wxWidgets 2.5.0 wxImage supports alpha channel data, that is
  315. in addition to a byte for the red, green and blue colour components for each
  316. pixel it also stores a byte representing the pixel opacity.
  317. An alpha value of 0 corresponds to a transparent pixel (null opacity) while
  318. a value of 255 means that the pixel is 100% opaque.
  319. The constants ::wxIMAGE_ALPHA_TRANSPARENT and ::wxIMAGE_ALPHA_OPAQUE can be
  320. used to indicate those values in a more readable form.
  321. While all images have RGB data, not all images have an alpha channel. Before
  322. using wxImage::GetAlpha you should check if this image contains an alpha
  323. channel with wxImage::HasAlpha. Currently the BMP, PNG, TGA, and TIFF format
  324. handlers have full alpha channel support for loading so if you want to use
  325. alpha you have to use one of these formats. If you initialize the image
  326. alpha channel yourself using wxImage::SetAlpha, you should save it in
  327. either PNG, TGA, or TIFF format to avoid losing it as these are the only
  328. handlers that currently support saving with alpha.
  329. @section image_handlers Available image handlers
  330. The following image handlers are available.
  331. wxBMPHandler is always installed by default.
  332. To use other image formats, install the appropriate handler with
  333. wxImage::AddHandler or call ::wxInitAllImageHandlers().
  334. - wxBMPHandler: For loading (including alpha support) and saving, always installed.
  335. - wxPNGHandler: For loading and saving. Includes alpha support.
  336. - wxJPEGHandler: For loading and saving.
  337. - wxGIFHandler: For loading and saving (see below).
  338. - wxPCXHandler: For loading and saving (see below).
  339. - wxPNMHandler: For loading and saving (see below).
  340. - wxTIFFHandler: For loading and saving. Includes alpha support.
  341. - wxTGAHandler: For loading and saving. Includes alpha support.
  342. - wxIFFHandler: For loading only.
  343. - wxXPMHandler: For loading and saving.
  344. - wxICOHandler: For loading and saving.
  345. - wxCURHandler: For loading and saving.
  346. - wxANIHandler: For loading only.
  347. When saving in PCX format, wxPCXHandler will count the number of different
  348. colours in the image; if there are 256 or less colours, it will save as 8 bit,
  349. else it will save as 24 bit.
  350. Loading PNMs only works for ASCII or raw RGB images.
  351. When saving in PNM format, wxPNMHandler will always save as raw RGB.
  352. Saving GIFs requires images of maximum 8 bpp (see wxQuantize), and the alpha channel converted to a mask (see wxImage::ConvertAlphaToMask).
  353. Saving an animated GIF requires images of the same size (see wxGIFHandler::SaveAnimation)
  354. @library{wxcore}
  355. @category{gdi}
  356. @stdobjects
  357. ::wxNullImage
  358. @see wxBitmap, wxInitAllImageHandlers(), wxPixelData
  359. */
  360. class wxImage : public wxObject
  361. {
  362. public:
  363. /**
  364. A simple class which stores red, green and blue values as 8 bit unsigned integers
  365. in the range of 0-255.
  366. */
  367. class RGBValue
  368. {
  369. public:
  370. /**
  371. Constructor for RGBValue, an object that contains values for red, green
  372. and blue which represent the value of a color.
  373. It is used by wxImage::HSVtoRGB and wxImage::RGBtoHSV, which convert
  374. between HSV color space and RGB color space.
  375. */
  376. RGBValue(unsigned char r=0, unsigned char g=0, unsigned char b=0);
  377. unsigned char red;
  378. unsigned char green;
  379. unsigned char blue;
  380. };
  381. /**
  382. A simple class which stores hue, saturation and value as doubles in the range 0.0-1.0.
  383. */
  384. class HSVValue
  385. {
  386. public:
  387. /**
  388. Constructor for HSVValue, an object that contains values for hue, saturation
  389. and value which represent the value of a color.
  390. It is used by wxImage::HSVtoRGB() and wxImage::RGBtoHSV(), which convert
  391. between HSV color space and RGB color space.
  392. */
  393. HSVValue(double h=0.0, double s=0.0, double v=0.0);
  394. double hue;
  395. double saturation;
  396. double value;
  397. };
  398. /**
  399. Creates an empty wxImage object without an alpha channel.
  400. */
  401. wxImage();
  402. /**
  403. Creates an image with the given size and clears it if requested.
  404. Does not create an alpha channel.
  405. @param width
  406. Specifies the width of the image.
  407. @param height
  408. Specifies the height of the image.
  409. @param clear
  410. If @true, initialize the image to black.
  411. */
  412. wxImage(int width, int height, bool clear = true);
  413. /**
  414. @overload
  415. */
  416. wxImage(const wxSize& sz, bool clear = true);
  417. /**
  418. Creates an image from data in memory. If @a static_data is @false
  419. then the wxImage will take ownership of the data and free it
  420. afterwards. For this, it has to be allocated with @e malloc.
  421. @param width
  422. Specifies the width of the image.
  423. @param height
  424. Specifies the height of the image.
  425. @param data
  426. A pointer to RGB data
  427. @param static_data
  428. Indicates if the data should be free'd after use
  429. */
  430. wxImage(int width, int height, unsigned char* data, bool static_data = false);
  431. /**
  432. @overload
  433. */
  434. wxImage(const wxSize& sz, unsigned char* data, bool static_data = false);
  435. /**
  436. Creates an image from data in memory. If @a static_data is @false
  437. then the wxImage will take ownership of the data and free it
  438. afterwards. For this, it has to be allocated with @e malloc.
  439. @param width
  440. Specifies the width of the image.
  441. @param height
  442. Specifies the height of the image.
  443. @param data
  444. A pointer to RGB data
  445. @param alpha
  446. A pointer to alpha-channel data
  447. @param static_data
  448. Indicates if the data should be free'd after use
  449. */
  450. wxImage(int width, int height, unsigned char* data, unsigned char* alpha,
  451. bool static_data = false );
  452. /**
  453. @overload
  454. */
  455. wxImage(const wxSize& sz, unsigned char* data, unsigned char* alpha,
  456. bool static_data = false);
  457. /**
  458. Creates an image from XPM data.
  459. @param xpmData
  460. A pointer to XPM image data.
  461. @beginWxPerlOnly
  462. Not supported by wxPerl.
  463. @endWxPerlOnly
  464. */
  465. wxImage(const char* const* xpmData);
  466. /**
  467. Creates an image from a file.
  468. @param name
  469. Name of the file from which to load the image.
  470. @param type
  471. May be one of the following:
  472. @li wxBITMAP_TYPE_BMP: Load a Windows bitmap file.
  473. @li wxBITMAP_TYPE_GIF: Load a GIF bitmap file.
  474. @li wxBITMAP_TYPE_JPEG: Load a JPEG bitmap file.
  475. @li wxBITMAP_TYPE_PNG: Load a PNG bitmap file.
  476. @li wxBITMAP_TYPE_PCX: Load a PCX bitmap file.
  477. @li wxBITMAP_TYPE_PNM: Load a PNM bitmap file.
  478. @li wxBITMAP_TYPE_TIFF: Load a TIFF bitmap file.
  479. @li wxBITMAP_TYPE_TGA: Load a TGA bitmap file.
  480. @li wxBITMAP_TYPE_XPM: Load a XPM bitmap file.
  481. @li wxBITMAP_TYPE_ICO: Load a Windows icon file (ICO).
  482. @li wxBITMAP_TYPE_CUR: Load a Windows cursor file (CUR).
  483. @li wxBITMAP_TYPE_ANI: Load a Windows animated cursor file (ANI).
  484. @li wxBITMAP_TYPE_ANY: Will try to autodetect the format.
  485. @param index
  486. Index of the image to load in the case that the image file contains
  487. multiple images. This is only used by GIF, ICO and TIFF handlers.
  488. The default value (-1) means "choose the default image" and is
  489. interpreted as the first image (index=0) by the GIF and TIFF handler
  490. and as the largest and most colourful one by the ICO handler.
  491. @remarks Depending on how wxWidgets has been configured and by which
  492. handlers have been loaded, not all formats may be available.
  493. Any handler other than BMP must be previously initialized with
  494. wxImage::AddHandler or wxInitAllImageHandlers.
  495. @note
  496. You can use GetOptionInt() to get the hotspot when loading cursor files:
  497. @code
  498. int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
  499. int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
  500. @endcode
  501. @see LoadFile()
  502. */
  503. wxImage(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1);
  504. /**
  505. Creates an image from a file using MIME-types to specify the type.
  506. @param name
  507. Name of the file from which to load the image.
  508. @param mimetype
  509. MIME type string (for example 'image/jpeg')
  510. @param index
  511. See description in wxImage(const wxString&, wxBitmapType, int) overload.
  512. */
  513. wxImage(const wxString& name, const wxString& mimetype, int index = -1);
  514. /**
  515. Creates an image from a stream.
  516. @param stream
  517. Opened input stream from which to load the image. Currently,
  518. the stream must support seeking.
  519. @param type
  520. See description in wxImage(const wxString&, wxBitmapType, int) overload.
  521. @param index
  522. See description in wxImage(const wxString&, wxBitmapType, int) overload.
  523. */
  524. wxImage(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1);
  525. /**
  526. Creates an image from a stream using MIME-types to specify the type.
  527. @param stream
  528. Opened input stream from which to load the image. Currently,
  529. the stream must support seeking.
  530. @param mimetype
  531. MIME type string (for example 'image/jpeg')
  532. @param index
  533. See description in wxImage(const wxString&, wxBitmapType, int) overload.
  534. */
  535. wxImage(wxInputStream& stream, const wxString& mimetype, int index = -1);
  536. /**
  537. Destructor.
  538. See @ref overview_refcount_destruct "reference-counted object destruction"
  539. for more info.
  540. */
  541. virtual ~wxImage();
  542. /**
  543. @name Image creation, initialization and deletion functions
  544. */
  545. //@{
  546. /**
  547. Returns an identical copy of this image.
  548. */
  549. wxImage Copy() const;
  550. /**
  551. Creates a fresh image.
  552. See wxImage::wxImage(int,int,bool) for more info.
  553. @return @true if the call succeeded, @false otherwise.
  554. */
  555. bool Create(int width, int height, bool clear = true);
  556. /**
  557. @overload
  558. */
  559. bool Create( const wxSize& sz, bool clear = true );
  560. /**
  561. Creates a fresh image.
  562. See wxImage::wxImage(int,int,unsigned char*,bool) for more info.
  563. @return @true if the call succeeded, @false otherwise.
  564. */
  565. bool Create( int width, int height, unsigned char* data, bool static_data = false );
  566. /**
  567. @overload
  568. */
  569. bool Create( const wxSize& sz, unsigned char* data, bool static_data = false );
  570. /**
  571. Creates a fresh image.
  572. See wxImage::wxImage(int,int,unsigned char*,unsigned char*,bool) for more info.
  573. @return @true if the call succeeded, @false otherwise.
  574. */
  575. bool Create( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data = false );
  576. /**
  577. @overload
  578. */
  579. bool Create( const wxSize& sz, unsigned char* data, unsigned char* alpha, bool static_data = false );
  580. /**
  581. Initialize the image data with zeroes (the default) or with the
  582. byte value given as @a value.
  583. @since 2.9.0
  584. */
  585. void Clear(unsigned char value = 0);
  586. /**
  587. Destroys the image data.
  588. */
  589. void Destroy();
  590. /**
  591. Initializes the image alpha channel data.
  592. It is an error to call it if the image already has alpha data.
  593. If it doesn't, alpha data will be by default initialized to all pixels
  594. being fully opaque. But if the image has a mask colour, all mask pixels
  595. will be completely transparent.
  596. */
  597. void InitAlpha();
  598. //@}
  599. /**
  600. @name Image manipulation functions
  601. */
  602. //@{
  603. /**
  604. Blurs the image in both horizontal and vertical directions by the
  605. specified pixel @a blurRadius. This should not be used when using
  606. a single mask colour for transparency.
  607. @see BlurHorizontal(), BlurVertical()
  608. */
  609. wxImage Blur(int blurRadius) const;
  610. /**
  611. Blurs the image in the horizontal direction only. This should not be used
  612. when using a single mask colour for transparency.
  613. @see Blur(), BlurVertical()
  614. */
  615. wxImage BlurHorizontal(int blurRadius) const;
  616. /**
  617. Blurs the image in the vertical direction only. This should not be used
  618. when using a single mask colour for transparency.
  619. @see Blur(), BlurHorizontal()
  620. */
  621. wxImage BlurVertical(int blurRadius) const;
  622. /**
  623. Returns a mirrored copy of the image.
  624. The parameter @a horizontally indicates the orientation.
  625. */
  626. wxImage Mirror(bool horizontally = true) const;
  627. /**
  628. Copy the data of the given @a image to the specified position in this image.
  629. */
  630. void Paste(const wxImage& image, int x, int y);
  631. /**
  632. Replaces the colour specified by @e r1,g1,b1 by the colour @e r2,g2,b2.
  633. */
  634. void Replace(unsigned char r1, unsigned char g1,
  635. unsigned char b1, unsigned char r2,
  636. unsigned char g2, unsigned char b2);
  637. /**
  638. Changes the size of the image in-place by scaling it: after a call to this
  639. function,the image will have the given width and height.
  640. For a description of the @a quality parameter, see the Scale() function.
  641. Returns the (modified) image itself.
  642. @see Scale()
  643. */
  644. wxImage& Rescale(int width, int height,
  645. wxImageResizeQuality quality = wxIMAGE_QUALITY_NORMAL);
  646. /**
  647. Changes the size of the image in-place without scaling it by adding either a
  648. border with the given colour or cropping as necessary.
  649. The image is pasted into a new image with the given @a size and background
  650. colour at the position @a pos relative to the upper left of the new image.
  651. If @a red = green = blue = -1 then use either the current mask colour
  652. if set or find, use, and set a suitable mask colour for any newly exposed
  653. areas.
  654. @return The (modified) image itself.
  655. @see Size()
  656. */
  657. wxImage& Resize(const wxSize& size, const wxPoint& pos, int red = -1,
  658. int green = -1, int blue = -1);
  659. /**
  660. Rotates the image about the given point, by @a angle radians.
  661. Passing @true to @a interpolating results in better image quality, but is slower.
  662. If the image has a mask, then the mask colour is used for the uncovered
  663. pixels in the rotated image background. Else, black (rgb 0, 0, 0) will be used.
  664. Returns the rotated image, leaving this image intact.
  665. */
  666. wxImage Rotate(double angle, const wxPoint& rotationCentre,
  667. bool interpolating = true,
  668. wxPoint* offsetAfterRotation = NULL) const;
  669. /**
  670. Returns a copy of the image rotated 90 degrees in the direction
  671. indicated by @a clockwise.
  672. */
  673. wxImage Rotate90(bool clockwise = true) const;
  674. /**
  675. Returns a copy of the image rotated by 180 degrees.
  676. @since 2.9.2
  677. */
  678. wxImage Rotate180() const;
  679. /**
  680. Rotates the hue of each pixel in the image by @e angle, which is a double in
  681. the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0
  682. corresponds to +360 degrees.
  683. */
  684. void RotateHue(double angle);
  685. /**
  686. Returns a scaled version of the image.
  687. This is also useful for scaling bitmaps in general as the only other way
  688. to scale bitmaps is to blit a wxMemoryDC into another wxMemoryDC.
  689. The parameter @a quality determines what method to use for resampling
  690. the image, see wxImageResizeQuality documentation.
  691. It should be noted that although using @c wxIMAGE_QUALITY_HIGH produces much nicer
  692. looking results it is a slower method. Downsampling will use the box averaging
  693. method which seems to operate very fast. If you are upsampling larger images using
  694. this method you will most likely notice that it is a bit slower and in extreme
  695. cases it will be quite substantially slower as the bicubic algorithm has to process a
  696. lot of data.
  697. It should also be noted that the high quality scaling may not work as expected
  698. when using a single mask colour for transparency, as the scaling will blur the
  699. image and will therefore remove the mask partially. Using the alpha channel
  700. will work.
  701. Example:
  702. @code
  703. // get the bitmap from somewhere
  704. wxBitmap bmp = ...;
  705. // rescale it to have size of 32*32
  706. if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 )
  707. {
  708. wxImage image = bmp.ConvertToImage();
  709. bmp = wxBitmap(image.Scale(32, 32));
  710. // another possibility:
  711. image.Rescale(32, 32);
  712. bmp = image;
  713. }
  714. @endcode
  715. @see Rescale()
  716. */
  717. wxImage Scale(int width, int height,
  718. wxImageResizeQuality quality = wxIMAGE_QUALITY_NORMAL) const;
  719. /**
  720. Returns a resized version of this image without scaling it by adding either a
  721. border with the given colour or cropping as necessary.
  722. The image is pasted into a new image with the given @a size and background
  723. colour at the position @a pos relative to the upper left of the new image.
  724. If @a red = green = blue = -1 then the areas of the larger image not covered
  725. by this image are made transparent by filling them with the image mask colour
  726. (which will be allocated automatically if it isn't currently set).
  727. Otherwise, the areas will be filled with the colour with the specified RGB components.
  728. @see Resize()
  729. */
  730. wxImage Size(const wxSize& size, const wxPoint& pos, int red = -1,
  731. int green = -1, int blue = -1) const;
  732. //@}
  733. /**
  734. @name Conversion functions
  735. */
  736. //@{
  737. /**
  738. If the image has alpha channel, this method converts it to mask.
  739. If the image has an alpha channel, all pixels with alpha value less
  740. than @a threshold are replaced with the mask colour and the alpha
  741. channel is removed. Otherwise nothing is done.
  742. The mask colour is chosen automatically using
  743. FindFirstUnusedColour() by this function, see the overload below if you
  744. this is not appropriate.
  745. @return Returns @true on success, @false on error.
  746. */
  747. bool ConvertAlphaToMask(unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD);
  748. /**
  749. If the image has alpha channel, this method converts it to mask using
  750. the specified colour as the mask colour.
  751. If the image has an alpha channel, all pixels with alpha value less
  752. than @a threshold are replaced with the mask colour and the alpha
  753. channel is removed. Otherwise nothing is done.
  754. @since 2.9.0
  755. @param mr
  756. The red component of the mask colour.
  757. @param mg
  758. The green component of the mask colour.
  759. @param mb
  760. The blue component of the mask colour.
  761. @param threshold
  762. Pixels with alpha channel values below the given threshold are
  763. considered to be transparent, i.e. the corresponding mask pixels
  764. are set. Pixels with the alpha values above the threshold are
  765. considered to be opaque.
  766. @return Returns @true on success, @false on error.
  767. */
  768. bool ConvertAlphaToMask(unsigned char mr, unsigned char mg, unsigned char mb,
  769. unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD);
  770. /**
  771. Returns a greyscale version of the image.
  772. The returned image uses the luminance component of the original to
  773. calculate the greyscale. Defaults to using the standard ITU-T BT.601
  774. when converting to YUV, where every pixel equals
  775. (R * @a weight_r) + (G * @a weight_g) + (B * @a weight_b).
  776. */
  777. wxImage ConvertToGreyscale(double weight_r, double weight_g, double weight_b) const;
  778. /**
  779. Returns a greyscale version of the image.
  780. @since 2.9.0
  781. */
  782. wxImage ConvertToGreyscale() const;
  783. /**
  784. Returns monochromatic version of the image.
  785. The returned image has white colour where the original has @e (r,g,b)
  786. colour and black colour everywhere else.
  787. */
  788. wxImage ConvertToMono(unsigned char r, unsigned char g, unsigned char b) const;
  789. /**
  790. Returns disabled (dimmed) version of the image.
  791. @since 2.9.0
  792. */
  793. wxImage ConvertToDisabled(unsigned char brightness = 255) const;
  794. //@}
  795. /**
  796. @name Miscellaneous functions
  797. */
  798. //@{
  799. /**
  800. Computes the histogram of the image. @a histogram is a reference to
  801. wxImageHistogram object. wxImageHistogram is a specialization of
  802. wxHashMap "template" and is defined as follows:
  803. @code
  804. class WXDLLEXPORT wxImageHistogramEntry
  805. {
  806. public:
  807. wxImageHistogramEntry() : index(0), value(0) {}
  808. unsigned long index;
  809. unsigned long value;
  810. };
  811. WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
  812. wxIntegerHash, wxIntegerEqual,
  813. wxImageHistogram);
  814. @endcode
  815. @return Returns number of colours in the histogram.
  816. */
  817. unsigned long ComputeHistogram(wxImageHistogram& histogram) const;
  818. /**
  819. Finds the first colour that is never used in the image.
  820. The search begins at given initial colour and continues by increasing
  821. R, G and B components (in this order) by 1 until an unused colour is
  822. found or the colour space exhausted.
  823. The parameters @a r, @a g, @a b are pointers to variables to save the colour.
  824. The parameters @a startR, @a startG, @a startB define the initial values
  825. of the colour.
  826. The returned colour will have RGB values equal to or greater than these.
  827. @return Returns @false if there is no unused colour left, @true on success.
  828. @note
  829. This method involves computing the histogram, which is a
  830. computationally intensive operation.
  831. */
  832. bool FindFirstUnusedColour(unsigned char* r, unsigned char* g,
  833. unsigned char* b, unsigned char startR = 1,
  834. unsigned char startG = 0,
  835. unsigned char startB = 0) const;
  836. /**
  837. Assignment operator, using @ref overview_refcount "reference counting".
  838. @param image
  839. Image to assign.
  840. @return Returns 'this' object.
  841. */
  842. wxImage& operator=(const wxImage& image);
  843. //@}
  844. /**
  845. @name Getters
  846. */
  847. //@{
  848. /**
  849. Returns pointer to the array storing the alpha values for this image.
  850. This pointer is @NULL for the images without the alpha channel. If the image
  851. does have it, this pointer may be used to directly manipulate the alpha values
  852. which are stored as the RGB ones.
  853. */
  854. unsigned char* GetAlpha() const;
  855. /**
  856. Returns the image data as an array.
  857. This is most often used when doing direct image manipulation.
  858. The return value points to an array of characters in RGBRGBRGB... format
  859. in the top-to-bottom, left-to-right order, that is the first RGB triplet
  860. corresponds to the first pixel of the first row, the second one ---
  861. to the second pixel of the first row and so on until the end of the first
  862. row, with second row following after it and so on.
  863. You should not delete the returned pointer nor pass it to SetData().
  864. */
  865. unsigned char* GetData() const;
  866. /**
  867. Return alpha value at given pixel location.
  868. */
  869. unsigned char GetAlpha(int x, int y) const;
  870. /**
  871. Returns the red intensity at the given coordinate.
  872. */
  873. unsigned char GetRed(int x, int y) const;
  874. /**
  875. Returns the green intensity at the given coordinate.
  876. */
  877. unsigned char GetGreen(int x, int y) const;
  878. /**
  879. Returns the blue intensity at the given coordinate.
  880. */
  881. unsigned char GetBlue(int x, int y) const;
  882. /**
  883. Gets the red value of the mask colour.
  884. */
  885. unsigned char GetMaskRed() const;
  886. /**
  887. Gets the green value of the mask colour.
  888. */
  889. unsigned char GetMaskGreen() const;
  890. /**
  891. Gets the blue value of the mask colour.
  892. */
  893. unsigned char GetMaskBlue() const;
  894. /**
  895. Gets the width of the image in pixels.
  896. @see GetHeight(), GetSize()
  897. */
  898. int GetWidth() const;
  899. /**
  900. Gets the height of the image in pixels.
  901. @see GetWidth(), GetSize()
  902. */
  903. int GetHeight() const;
  904. /**
  905. Returns the size of the image in pixels.
  906. @since 2.9.0
  907. @see GetHeight(), GetWidth()
  908. */
  909. wxSize GetSize() const;
  910. /**
  911. Gets a user-defined string-valued option.
  912. Generic options:
  913. @li @c wxIMAGE_OPTION_FILENAME: The name of the file from which the image
  914. was loaded.
  915. Options specific to wxGIFHandler:
  916. @li @c wxIMAGE_OPTION_GIF_COMMENT: The comment text that is read from
  917. or written to the GIF file. In an animated GIF each frame can have
  918. its own comment. If there is only a comment in the first frame of
  919. a GIF it will not be repeated in other frames.
  920. @param name
  921. The name of the option, case-insensitive.
  922. @return
  923. The value of the option or an empty string if not found. Use
  924. HasOption() if an empty string can be a valid option value.
  925. @see SetOption(), GetOptionInt(), HasOption()
  926. */
  927. wxString GetOption(const wxString& name) const;
  928. /**
  929. Gets a user-defined integer-valued option.
  930. The function is case-insensitive to @a name.
  931. If the given option is not present, the function returns 0.
  932. Use HasOption() if 0 is a possibly valid value for the option.
  933. Generic options:
  934. @li @c wxIMAGE_OPTION_MAX_WIDTH and @c wxIMAGE_OPTION_MAX_HEIGHT: If either
  935. of these options is specified, the loaded image will be scaled down
  936. (preserving its aspect ratio) so that its width is less than the
  937. max width given if it is not 0 @em and its height is less than the
  938. max height given if it is not 0. This is typically used for loading
  939. thumbnails and the advantage of using these options compared to
  940. calling Rescale() after loading is that some handlers (only JPEG
  941. one right now) support rescaling the image during loading which is
  942. vastly more efficient than loading the entire huge image and
  943. rescaling it later (if these options are not supported by the
  944. handler, this is still what happens however). These options must be
  945. set before calling LoadFile() to have any effect.
  946. @li @c wxIMAGE_OPTION_ORIGINAL_WIDTH and @c wxIMAGE_OPTION_ORIGINAL_HEIGHT:
  947. These options will return the original size of the image if either
  948. @c wxIMAGE_OPTION_MAX_WIDTH or @c wxIMAGE_OPTION_MAX_HEIGHT is
  949. specified.
  950. @since 2.9.3
  951. @li @c wxIMAGE_OPTION_QUALITY: JPEG quality used when saving. This is an
  952. integer in 0..100 range with 0 meaning very poor and 100 excellent
  953. (but very badly compressed). This option is currently ignored for
  954. the other formats.
  955. @li @c wxIMAGE_OPTION_RESOLUTIONUNIT: The value of this option determines
  956. whether the resolution of the image is specified in centimetres or
  957. inches, see wxImageResolution enum elements.
  958. @li @c wxIMAGE_OPTION_RESOLUTION, @c wxIMAGE_OPTION_RESOLUTIONX and
  959. @c wxIMAGE_OPTION_RESOLUTIONY: These options define the resolution of
  960. the image in the units corresponding to @c wxIMAGE_OPTION_RESOLUTIONUNIT
  961. options value. The first option can be set before saving the image
  962. to set both horizontal and vertical resolution to the same value.
  963. The X and Y options are set by the image handlers if they support
  964. the image resolution (currently BMP, JPEG and TIFF handlers do) and
  965. the image provides the resolution information and can be queried
  966. after loading the image.
  967. Options specific to wxPNGHandler:
  968. @li @c wxIMAGE_OPTION_PNG_FORMAT: Format for saving a PNG file, see
  969. wxImagePNGType for the supported values.
  970. @li @c wxIMAGE_OPTION_PNG_BITDEPTH: Bit depth for every channel (R/G/B/A).
  971. @li @c wxIMAGE_OPTION_PNG_FILTER: Filter for saving a PNG file, see libpng
  972. (http://www.libpng.org/pub/png/libpng-1.2.5-manual.html) for possible values
  973. (e.g. PNG_FILTER_NONE, PNG_FILTER_SUB, PNG_FILTER_UP, etc).
  974. @li @c wxIMAGE_OPTION_PNG_COMPRESSION_LEVEL: Compression level (0..9) for
  975. saving a PNG file. An high value creates smaller-but-slower PNG file.
  976. Note that unlike other formats (e.g. JPEG) the PNG format is always
  977. lossless and thus this compression level doesn't tradeoff the image
  978. quality.
  979. @li @c wxIMAGE_OPTION_PNG_COMPRESSION_MEM_LEVEL: Compression memory usage
  980. level (1..9) for saving a PNG file. An high value means the saving
  981. process consumes more memory, but may create smaller PNG file.
  982. @li @c wxIMAGE_OPTION_PNG_COMPRESSION_STRATEGY: Possible values are 0 for
  983. default strategy, 1 for filter, and 2 for Huffman-only.
  984. You can use OptiPNG (http://optipng.sourceforge.net/) to get a suitable
  985. value for your application.
  986. @li @c wxIMAGE_OPTION_PNG_COMPRESSION_BUFFER_SIZE: Internal buffer size
  987. (in bytes) for saving a PNG file. Ideally this should be as big as
  988. the resulting PNG file. Use this option if your application produces
  989. images with small size variation.
  990. Options specific to wxTIFFHandler:
  991. @li @c wxIMAGE_OPTION_TIFF_BITSPERSAMPLE: Number of bits per
  992. sample (channel). Currently values of 1 and 8 are supported. A
  993. value of 1 results in a black and white image. A value of 8 (the
  994. default) can mean greyscale or RGB, depending on the value of
  995. @c wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL.
  996. @li @c wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL: Number of samples
  997. (channels) per pixel. Currently values of 1 and 3 are supported.
  998. A value of 1 results in either a greyscale (by default) or black and
  999. white image, depending on the value of
  1000. @c wxIMAGE_OPTION_TIFF_BITSPERSAMPLE. A value of 3 (the default)
  1001. will result in an RGB image.
  1002. @li @c wxIMAGE_OPTION_TIFF_COMPRESSION: Compression type. By default
  1003. it is set to 1 (COMPRESSION_NONE). Typical other values are
  1004. 5 (COMPRESSION_LZW) and 7 (COMPRESSION_JPEG). See tiff.h for more
  1005. options.
  1006. @li @c wxIMAGE_OPTION_TIFF_PHOTOMETRIC: Specifies the photometric
  1007. interpretation. By default it is set to 2 (PHOTOMETRIC_RGB) for RGB
  1008. images and 0 (PHOTOMETRIC_MINISWHITE) for greyscale or black and
  1009. white images. It can also be set to 1 (PHOTOMETRIC_MINISBLACK) to
  1010. treat the lowest value as black and highest as white.
  1011. If you want a greyscale image it is also sufficient to only specify
  1012. @c wxIMAGE_OPTION_TIFF_PHOTOMETRIC and set it to either
  1013. PHOTOMETRIC_MINISWHITE or PHOTOMETRIC_MINISBLACK. The other values
  1014. are taken care of.
  1015. @note
  1016. Be careful when combining the options @c wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL,
  1017. @c wxIMAGE_OPTION_TIFF_BITSPERSAMPLE, and @c wxIMAGE_OPTION_TIFF_PHOTOMETRIC.
  1018. While some measures are taken to prevent illegal combinations and/or
  1019. values, it is still easy to abuse them and come up with invalid
  1020. results in the form of either corrupted images or crashes.
  1021. @param name
  1022. The name of the option, case-insensitive.
  1023. @return
  1024. The value of the option or 0 if not found.
  1025. Use HasOption() if 0 can be a valid option value.
  1026. @see SetOption(), GetOption()
  1027. */
  1028. int GetOptionInt(const wxString& name) const;
  1029. /**
  1030. Get the current mask colour or find a suitable unused colour that could be
  1031. used as a mask colour. Returns @true if the image currently has a mask.
  1032. */
  1033. bool GetOrFindMaskColour(unsigned char* r, unsigned char* g,
  1034. unsigned char* b) const;
  1035. /**
  1036. Returns the palette associated with the image.
  1037. Currently the palette is only used when converting to wxBitmap under Windows.
  1038. Some of the wxImage handlers have been modified to set the palette if
  1039. one exists in the image file (usually 256 or less colour images in
  1040. GIF or PNG format).
  1041. */
  1042. const wxPalette& GetPalette() const;
  1043. /**
  1044. Returns a sub image of the current one as long as the rect belongs entirely
  1045. to the image.
  1046. */
  1047. wxImage GetSubImage(const wxRect& rect) const;
  1048. /**
  1049. Gets the type of image found by LoadFile() or specified with SaveFile().
  1050. @since 2.9.0
  1051. */
  1052. wxBitmapType GetType() const;
  1053. /**
  1054. Returns @true if this image has alpha channel, @false otherwise.
  1055. @see GetAlpha(), SetAlpha()
  1056. */
  1057. bool HasAlpha() const;
  1058. /**
  1059. Returns @true if there is a mask active, @false otherwise.
  1060. */
  1061. bool HasMask() const;
  1062. /**
  1063. Returns @true if the given option is present.
  1064. The function is case-insensitive to @a name.
  1065. The lists of the currently supported options are in GetOption() and
  1066. GetOptionInt() function docs.
  1067. @see SetOption(), GetOption(), GetOptionInt()
  1068. */
  1069. bool HasOption(const wxString& name) const;
  1070. /**
  1071. Returns @true if image data is present.
  1072. */
  1073. bool IsOk() const;
  1074. /**
  1075. Returns @true if the given pixel is transparent, i.e.\ either has the mask
  1076. colour if this image has a mask or if this image has alpha channel and alpha
  1077. value of this pixel is strictly less than @a threshold.
  1078. */
  1079. bool IsTransparent(int x, int y,
  1080. unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD) const;
  1081. //@}
  1082. /**
  1083. @name Loading and saving functions
  1084. */
  1085. //@{
  1086. /**
  1087. Loads an image from an input stream.
  1088. @param stream
  1089. Opened input stream from which to load the image.
  1090. Currently, the stream must support seeking.
  1091. @param type
  1092. May be one of the following:
  1093. @li wxBITMAP_TYPE_BMP: Load a Windows bitmap file.
  1094. @li wxBITMAP_TYPE_GIF: Load a GIF bitmap file.
  1095. @li wxBITMAP_TYPE_JPEG: Load a JPEG bitmap file.
  1096. @li wxBITMAP_TYPE_PNG: Load a PNG bitmap file.
  1097. @li wxBITMAP_TYPE_PCX: Load a PCX bitmap file.
  1098. @li wxBITMAP_TYPE_PNM: Load a PNM bitmap file.
  1099. @li wxBITMAP_TYPE_TIFF: Load a TIFF bitmap file.
  1100. @li wxBITMAP_TYPE_TGA: Load a TGA bitmap file.
  1101. @li wxBITMAP_TYPE_XPM: Load a XPM bitmap file.
  1102. @li wxBITMAP_TYPE_ICO: Load a Windows icon file (ICO).
  1103. @li wxBITMAP_TYPE_CUR: Load a Windows cursor file (CUR).
  1104. @li wxBITMAP_TYPE_ANI: Load a Windows animated cursor file (ANI).
  1105. @li wxBITMAP_TYPE_ANY: Will try to autodetect the format.
  1106. @param index
  1107. Index of the image to load in the case that the image file contains
  1108. multiple images. This is only used by GIF, ICO and TIFF handlers.
  1109. The default value (-1) means "choose the default image" and is
  1110. interpreted as the first image (index=0) by the GIF and TIFF handler
  1111. and as the largest and most colourful one by the ICO handler.
  1112. @return @true if the operation succeeded, @false otherwise.
  1113. If the optional index parameter is out of range, @false is
  1114. returned and a call to wxLogError() takes place.
  1115. @remarks Depending on how wxWidgets has been configured, not all formats
  1116. may be available.
  1117. @note
  1118. You can use GetOptionInt() to get the hotspot when loading cursor files:
  1119. @code
  1120. int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
  1121. int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
  1122. @endcode
  1123. @see SaveFile()
  1124. */
  1125. virtual bool LoadFile(wxInputStream& stream,
  1126. wxBitmapType type = wxBITMAP_TYPE_ANY,
  1127. int index = -1);
  1128. /**
  1129. Loads an image from a file.
  1130. If no handler type is provided, the library will try to autodetect the format.
  1131. @param name
  1132. Name of the file from which to load the image.
  1133. @param type
  1134. See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.
  1135. @param index
  1136. See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.
  1137. */
  1138. virtual bool LoadFile(const wxString& name,
  1139. wxBitmapType type = wxBITMAP_TYPE_ANY,
  1140. int index = -1);
  1141. /**
  1142. Loads an image from a file.
  1143. If no handler type is provided, the library will try to autodetect the format.
  1144. @param name
  1145. Name of the file from which to load the image.
  1146. @param mimetype
  1147. MIME type string (for example 'image/jpeg')
  1148. @param index
  1149. See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.
  1150. */
  1151. virtual bool LoadFile(const wxString& name, const wxString& mimetype,
  1152. int index = -1);
  1153. /**
  1154. Loads an image from an input stream.
  1155. @param stream
  1156. Opened input stream from which to load the image.
  1157. Currently, the stream must support seeking.
  1158. @param mimetype
  1159. MIME type string (for example 'image/jpeg')
  1160. @param index
  1161. See the description in the LoadFile(wxInputStream&, wxBitmapType, int) overload.
  1162. */
  1163. virtual bool LoadFile(wxInputStream& stream, const wxString& mimetype,
  1164. int index = -1);
  1165. /**
  1166. Saves an image in the given stream.
  1167. @param stream
  1168. Opened output stream to save the image to.
  1169. @param mimetype
  1170. MIME type.
  1171. @return @true if the operation succeeded, @false otherwise.
  1172. @remarks Depending on how wxWidgets has been configured, not all formats
  1173. may be available.
  1174. @note
  1175. You can use SetOption() to set the hotspot when saving an image
  1176. into a cursor file (default hotspot is in the centre of the image):
  1177. @code
  1178. image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
  1179. image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);
  1180. @endcode
  1181. @see LoadFile()
  1182. */
  1183. virtual bool SaveFile(wxOutputStream& stream,
  1184. const wxString& mimetype) const;
  1185. /**
  1186. Saves an image in the named file.
  1187. @param name
  1188. Name of the file to save the image to.
  1189. @param type
  1190. Currently these types can be used:
  1191. @li wxBITMAP_TYPE_BMP: Save a BMP image file.
  1192. @li wxBITMAP_TYPE_JPEG: Save a JPEG image file.
  1193. @li wxBITMAP_TYPE_PNG: Save a PNG image file.
  1194. @li wxBITMAP_TYPE_PCX: Save a PCX image file
  1195. (tries to save as 8-bit if possible, falls back to 24-bit otherwise).
  1196. @li wxBITMAP_TYPE_PNM: Save a PNM image file (as raw RGB always).
  1197. @li wxBITMAP_TYPE_TIFF: Save a TIFF image file.
  1198. @li wxBITMAP_TYPE_XPM: Save a XPM image file.
  1199. @li wxBITMAP_TYPE_ICO: Save a Windows icon file (ICO).
  1200. The size may be up to 255 wide by 127 high. A single image is saved
  1201. in 8 colors at the size supplied.
  1202. @li wxBITMAP_TYPE_CUR: Save a Windows cursor file (CUR).
  1203. */
  1204. virtual bool SaveFile(const wxString& name, wxBitmapType type) const;
  1205. /**
  1206. Saves an image in the named file.
  1207. @param name
  1208. Name of the file to save the image to.
  1209. @param mimetype
  1210. MIME type.
  1211. */
  1212. virtual bool SaveFile(const wxString& name, const wxString& mimetype) const;
  1213. /**
  1214. Saves an image in the named file.
  1215. File type is determined from the extension of the file name.
  1216. Note that this function may fail if the extension is not recognized!
  1217. You can use one of the forms above to save images to files with
  1218. non-standard extensions.
  1219. @param name
  1220. Name of the file to save the image to.
  1221. */
  1222. virtual bool SaveFile(const wxString& name) const;
  1223. /**
  1224. Saves an image in the given stream.
  1225. @param stream
  1226. Opened output stream to save the image to.
  1227. @param type
  1228. MIME type.
  1229. */
  1230. virtual bool SaveFile(wxOutputStream& stream, wxBitmapType type) const;
  1231. //@}
  1232. /**
  1233. @name Setters
  1234. */
  1235. //@{
  1236. /**
  1237. This function is similar to SetData() and has similar restrictions.
  1238. The pointer passed to it may however be @NULL in which case the function
  1239. will allocate the alpha array internally -- this is useful to add alpha
  1240. channel data to an image which doesn't have any.
  1241. If the pointer is not @NULL, it must have one byte for each image pixel
  1242. and be allocated with malloc().
  1243. wxImage takes ownership of the pointer and will free it unless @a static_data
  1244. parameter is set to @true -- in this case the caller should do it.
  1245. */
  1246. void SetAlpha(unsigned char* alpha = NULL,
  1247. bool static_data = false);
  1248. /**
  1249. Sets the alpha value for the given pixel.
  1250. This function should only be called if the image has alpha channel data,
  1251. use HasAlpha() to check for this.
  1252. */
  1253. void SetAlpha(int x, int y, unsigned char alpha);
  1254. /**
  1255. Removes the alpha channel from the image.
  1256. This function should only be called if the image has alpha channel data,
  1257. use HasAlpha() to check for this.
  1258. @since 2.9.1
  1259. */
  1260. void ClearAlpha();
  1261. /**
  1262. Sets the image data without performing checks.
  1263. The data given must have the size (width*height*3) or results will be
  1264. unexpected. Don't use this method if you aren't sure you know what you
  1265. are doing.
  1266. The data must have been allocated with @c malloc(), @b NOT with
  1267. @c operator new.
  1268. If @a static_data is @false, after this call the pointer to the data is
  1269. owned by the wxImage object, that will be responsible for deleting it.
  1270. Do not pass to this function a pointer obtained through GetData().
  1271. */
  1272. void SetData(unsigned char* data, bool static_data = false);
  1273. /**
  1274. @overload
  1275. */
  1276. void SetData(unsigned char* data, int new_width, int new_height,
  1277. bool static_data = false);
  1278. /**
  1279. Specifies whether there is a mask or not.
  1280. The area of the mask is determined by the current mask colour.
  1281. */
  1282. void SetMask(bool hasMask = true);
  1283. /**
  1284. Sets the mask colour for this image (and tells the image to use the mask).
  1285. */
  1286. void SetMaskColour(unsigned char red, unsigned char green,
  1287. unsigned char blue);
  1288. /**
  1289. Sets image's mask so that the pixels that have RGB value of mr,mg,mb in
  1290. mask will be masked in the image.
  1291. This is done by first finding an unused colour in the image, setting
  1292. this colour as the mask colour and then using this colour to draw all
  1293. pixels in the image who corresponding pixel in mask has given RGB value.
  1294. The parameter @a mask is the mask image to extract mask shape from.
  1295. It must have the same dimensions as the image.
  1296. The parameters @a mr, @a mg, @a mb are the RGB values of the pixels in
  1297. mask that will be used to create the mask.
  1298. @return Returns @false if mask does not have same dimensions as the image
  1299. or if there is no unused colour left. Returns @true if the mask
  1300. was successfully applied.
  1301. @note
  1302. Note that this method involves computing the histogram, which is a
  1303. computationally intensive operation.
  1304. */
  1305. bool SetMaskFromImage(const wxImage& mask, unsigned char mr,
  1306. unsigned char mg,
  1307. unsigned char mb);
  1308. /**
  1309. Sets a user-defined option. The function is case-insensitive to @a name.
  1310. For example, when saving as a JPEG file, the option @b quality is
  1311. used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
  1312. The lists of the currently supported options are in GetOption() and
  1313. GetOptionInt() function docs.
  1314. @see GetOption(), GetOptionInt(), HasOption()
  1315. */
  1316. void SetOption(const wxString& name, const wxString& value);
  1317. /**
  1318. @overload
  1319. */
  1320. void SetOption(const wxString& name, int value);
  1321. /**
  1322. Associates a palette with the image.
  1323. The palette may be used when converting wxImage to wxBitmap (MSW only at present)
  1324. or in file save operations (none as yet).
  1325. */
  1326. void SetPalette(const wxPalette& palette);
  1327. /**
  1328. Set the color of the pixel at the given x and y coordinate.
  1329. */
  1330. void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
  1331. /**
  1332. Sets the colour of the pixels within the given rectangle.
  1333. This routine performs bounds-checks for the coordinate so it can be considered
  1334. a safe way to manipulate the data.
  1335. */
  1336. void SetRGB(const wxRect& rect,
  1337. unsigned char red,
  1338. unsigned char green,
  1339. unsigned char blue);
  1340. /**
  1341. Set the type of image returned by GetType().
  1342. This method is mostly used internally by the library but can also be
  1343. called from the user code if the image was created from data in the
  1344. given bitmap format without using LoadFile() (which would set the type
  1345. correctly automatically).
  1346. Notice that the image must be created before this function is called.
  1347. @since 2.9.0
  1348. @param type
  1349. One of bitmap type constants, @c wxBITMAP_TYPE_INVALID is a valid
  1350. value for it and can be used to reset the bitmap type to default
  1351. but @c wxBITMAP_TYPE_MAX is not allowed here.
  1352. */
  1353. void SetType(wxBitmapType type);
  1354. //@}
  1355. /**
  1356. @name Handler management functions
  1357. */
  1358. //@{
  1359. /**
  1360. Register an image handler.
  1361. Typical example of use:
  1362. @code
  1363. wxImage::AddHandler(new wxPNGHandler);
  1364. @endcode
  1365. See @ref image_handlers for a list of the available handlers. You can
  1366. also use ::wxInitAllImageHandlers() to add handlers for all the image
  1367. formats supported by wxWidgets at once.
  1368. @param handler
  1369. A heap-allocated handler object which will be deleted by wxImage
  1370. if it is removed later by RemoveHandler() or at program shutdown.
  1371. */
  1372. static void AddHandler(wxImageHandler* handler);
  1373. /**
  1374. Deletes all image handlers.
  1375. This function is called by wxWidgets on exit.
  1376. */
  1377. static void CleanUpHandlers();
  1378. /**
  1379. Finds the handler with the given name.
  1380. @param name
  1381. The handler name.
  1382. @return A pointer to the handler if found, @NULL otherwise.
  1383. @see wxImageHandler
  1384. */
  1385. static wxImageHandler* FindHandler(const wxString& name);
  1386. /**
  1387. Finds the handler associated with the given extension and type.
  1388. @param extension
  1389. The file extension, such as "bmp".
  1390. @param imageType
  1391. The image type; one of the ::wxBitmapType values.
  1392. @return A pointer to the handler if found, @NULL otherwise.
  1393. @see wxImageHandler
  1394. */
  1395. static wxImageHandler* FindHandler(const wxString& extension,
  1396. wxBitmapType imageType);
  1397. /**
  1398. Finds the handler associated with the given image type.
  1399. @param imageType
  1400. The image type; one of the ::wxBitmapType values.
  1401. @return A pointer to the handler if found, @NULL otherwise.
  1402. @see wxImageHandler
  1403. */
  1404. static wxImageHandler* FindHandler(wxBitmapType imageType);
  1405. /**
  1406. Finds the handler associated with the given MIME type.
  1407. @param mimetype
  1408. MIME type.
  1409. @return A pointer to the handler if found, @NULL otherwise.
  1410. @see wxImageHandler
  1411. */
  1412. static wxImageHandler* FindHandlerMime(const wxString& mimetype);
  1413. /**
  1414. Returns the static list of image format handlers.
  1415. @see wxImageHandler
  1416. */
  1417. static wxList& GetHandlers();
  1418. /**
  1419. Internal use only. Adds standard image format handlers.
  1420. It only install wxBMPHandler for the time being, which is used by wxBitmap.
  1421. This function is called by wxWidgets on startup, and shouldn't be called by
  1422. the user.
  1423. @see wxImageHandler, wxInitAllImageHandlers(), wxQuantize
  1424. */
  1425. static void InitStandardHandlers();
  1426. /**
  1427. Adds a handler at the start of the static list of format handlers.
  1428. @param handler
  1429. A new image format handler object. There is usually only one instance
  1430. of a given handler class in an application session.
  1431. @see wxImageHandler
  1432. */
  1433. static void InsertHandler(wxImageHandler* handler);
  1434. /**
  1435. Finds the handler with the given name, and removes it.
  1436. The handler is also deleted.
  1437. @param name
  1438. The handler name.
  1439. @return @true if the handler was found and removed, @false otherwise.
  1440. @see wxImageHandler
  1441. */
  1442. static bool RemoveHandler(const wxString& name);
  1443. //@}
  1444. /**
  1445. Returns @true if at least one of the available image handlers can read
  1446. the file with the given name.
  1447. See wxImageHandler::CanRead for more info.
  1448. */
  1449. static bool CanRead(const wxString& filename);
  1450. /**
  1451. Returns @true if at least one of the available image handlers can read
  1452. the data in the given stream.
  1453. See wxImageHandler::CanRead for more info.
  1454. */
  1455. static bool CanRead(wxInputStream& stream);
  1456. //@{
  1457. /**
  1458. If the image file contains more than one image and the image handler is
  1459. capable of retrieving these individually, this function will return the
  1460. number of available images.
  1461. For the overload taking the parameter @a filename, that's the name
  1462. of the file to query.
  1463. For the overload taking the parameter @a stream, that's the opened input
  1464. stream with image data.
  1465. See wxImageHandler::GetImageCount() for more info.
  1466. The parameter @a type may be one of the following values:
  1467. @li wxBITMAP_TYPE_BMP: Load a Windows bitmap file.
  1468. @li wxBITMAP_TYPE_GIF: Load a GIF bitmap file.
  1469. @li wxBITMAP_TYPE_JPEG: Load a JPEG bitmap file.
  1470. @li wxBITMAP_TYPE_PNG: Load a PNG bitmap file.
  1471. @li wxBITMAP_TYPE_PCX: Load a PCX bitmap file.
  1472. @li wxBITMAP_TYPE_PNM: Load a PNM bitmap file.
  1473. @li wxBITMAP_TYPE_TIFF: Load a TIFF bitmap file.
  1474. @li wxBITMAP_TYPE_TGA: Load a TGA bitmap file.
  1475. @li wxBITMAP_TYPE_XPM: Load a XPM bitmap file.
  1476. @li wxBITMAP_TYPE_ICO: Load a Windows icon file (ICO).
  1477. @li wxBITMAP_TYPE_CUR: Load a Windows cursor file (CUR).
  1478. @li wxBITMAP_TYPE_ANI: Load a Windows animated cursor file (ANI).
  1479. @li wxBITMAP_TYPE_ANY: Will try to autodetect the format.
  1480. @return Number of available images. For most image handlers, this is 1
  1481. (exceptions are TIFF and ICO formats as well as animated GIFs
  1482. for which this function returns the number of frames in the
  1483. animation).
  1484. */
  1485. static int GetImageCount(const wxString& filename,
  1486. wxBitmapType type = wxBITMAP_TYPE_ANY);
  1487. static int GetImageCount(wxInputStream& stream,
  1488. wxBitmapType type = wxBITMAP_TYPE_ANY);
  1489. //@}
  1490. /**
  1491. Iterates all registered wxImageHandler objects, and returns a string containing
  1492. file extension masks suitable for passing to file open/save dialog boxes.
  1493. @return The format of the returned string is @c "(*.ext1;*.ext2)|*.ext1;*.ext2".
  1494. It is usually a good idea to prepend a description before passing
  1495. the result to the dialog.
  1496. Example:
  1497. @code
  1498. wxFileDialog FileDlg( this, "Choose Image", ::wxGetCwd(), "",
  1499. _("Image Files ") + wxImage::GetImageExtWildcard(),
  1500. wxFD_OPEN );
  1501. @endcode
  1502. @see wxImageHandler
  1503. */
  1504. static wxString GetImageExtWildcard();
  1505. /**
  1506. Converts a color in RGB color space to HSV color space.
  1507. */
  1508. static wxImage::HSVValue RGBtoHSV(const wxImage::RGBValue& rgb);
  1509. /**
  1510. Converts a color in HSV color space to RGB color space.
  1511. */
  1512. static wxImage::RGBValue HSVtoRGB(const wxImage::HSVValue& hsv);
  1513. };
  1514. class wxImageHistogram : public wxImageHistogramBase
  1515. {
  1516. public:
  1517. wxImageHistogram();
  1518. // get the key in the histogram for the given RGB values
  1519. static unsigned long MakeKey(unsigned char r,
  1520. unsigned char g,
  1521. unsigned char b);
  1522. // find first colour that is not used in the image and has higher
  1523. // RGB values than RGB(startR, startG, startB)
  1524. //
  1525. // returns true and puts this colour in r, g, b (each of which may be NULL)
  1526. // on success or returns false if there are no more free colours
  1527. bool FindFirstUnusedColour(unsigned char *r,
  1528. unsigned char *g,
  1529. unsigned char *b,
  1530. unsigned char startR = 1,
  1531. unsigned char startG = 0,
  1532. unsigned char startB = 0 ) const;
  1533. };
  1534. /**
  1535. An instance of an empty image without an alpha channel.
  1536. */
  1537. wxImage wxNullImage;
  1538. // ============================================================================
  1539. // Global functions/macros
  1540. // ============================================================================
  1541. /** @addtogroup group_funcmacro_appinitterm */
  1542. //@{
  1543. /**
  1544. Initializes all available image handlers.
  1545. This function calls wxImage::AddHandler() for all the available image
  1546. handlers (see @ref image_handlers for the full list). Calling it is the
  1547. simplest way to initialize wxImage but it creates and registers even the
  1548. handlers your program may not use. If you want to avoid the overhead of
  1549. doing this you need to call wxImage::AddHandler() manually just for the
  1550. handlers that you do want to use.
  1551. @see wxImage, wxImageHandler
  1552. @header{wx/image.h}
  1553. */
  1554. void wxInitAllImageHandlers();
  1555. //@}