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