add support for multiple extensions to wxImage handlers (closes #10570)
[wxWidgets.git] / interface / wx / image.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: image.h
3 // Purpose: interface of wxImageHandler and wxImage
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
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
38 /**
39 @class wxImageHandler
40
41 This is the base class for implementing image file loading/saving, and
42 image creation from data.
43 It is used within wxImage and is not normally seen by the application.
44
45 If you wish to extend the capabilities of wxImage, derive a class from
46 wxImageHandler and add the handler using wxImage::AddHandler in your
47 application initialization.
48
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
62 @stdobjects
63 ::wxNullImage
64
65 @library{wxcore}
66 @category{gdi}
67
68 @see wxImage, wxInitAllImageHandlers()
69 */
70 class wxImageHandler : public wxObject
71 {
72 public:
73 /**
74 Default constructor.
75
76 In your own default constructor, initialise the members
77 m_name, m_extension and m_type.
78 */
79 wxImageHandler();
80
81 /**
82 Destroys the wxImageHandler object.
83 */
84 virtual ~wxImageHandler();
85
86 /**
87 Gets the preferred file extension associated with this handler.
88
89 @see GetAltExtensions()
90 */
91 const wxString& GetExtension() const;
92
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
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.
106
107 @param stream
108 Opened input stream for reading image data.
109 Currently, the stream must support seeking.
110
111 @return Number of available images. For most image handlers, this is 1
112 (exceptions are TIFF and ICO formats).
113 */
114 virtual int GetImageCount(wxInputStream& stream);
115
116 /**
117 Gets the MIME type associated with this handler.
118 */
119 const wxString& GetMimeType() const;
120
121 /**
122 Gets the name of this handler.
123 */
124 const wxString& GetName() const;
125
126 /**
127 Gets the image type associated with this handler.
128 */
129 wxBitmapType GetType() const;
130
131 /**
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.
137
138 @param image
139 The image object which is to be affected by this operation.
140 @param stream
141 Opened input stream for reading image data.
142 @param verbose
143 If set to @true, errors reported by the image handler will produce
144 wxLogMessages.
145 @param index
146 The index of the image in the file (starting from zero).
147
148 @return @true if the operation succeeded, @false otherwise.
149
150 @see wxImage::LoadFile, wxImage::SaveFile, SaveFile()
151 */
152 virtual bool LoadFile(wxImage* image, wxInputStream& stream,
153 bool verbose = true, int index = -1);
154
155 /**
156 Saves a image in the output stream.
157
158 @param image
159 The image object which is to be affected by this operation.
160 @param stream
161 Opened output stream for writing the data.
162 @param verbose
163 If set to @true, errors reported by the image handler will produce
164 wxLogMessages.
165
166 @return @true if the operation succeeded, @false otherwise.
167
168 @see wxImage::LoadFile, wxImage::SaveFile, LoadFile()
169 */
170 virtual bool SaveFile(wxImage* image, wxOutputStream& stream,
171 bool verbose = true);
172
173 /**
174 Sets the preferred file extension associated with this handler.
175
176 @param extension
177 File extension without leading dot.
178
179 @see SetAltExtensions()
180 */
181 void SetExtension(const wxString& extension);
182
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
195 /**
196 Sets the handler MIME type.
197
198 @param mimetype
199 Handler MIME type.
200 */
201 void SetMimeType(const wxString& mimetype);
202
203 /**
204 Sets the handler name.
205
206 @param name
207 Handler name.
208 */
209 void SetName(const wxString& name);
210 };
211
212
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;
224
225 /**
226 @class wxImage
227
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
233 get image bits, so it can be used for basic image manipulation.
234
235 A wxImage cannot (currently) be drawn directly to a wxDC.
236 Instead, a platform-specific wxBitmap object must be created from it using
237 the wxBitmap::wxBitmap(wxImage,int depth) constructor.
238 This bitmap can then be drawn in a device context, using wxDC::DrawBitmap.
239
240 One colour value of the image may be used as a mask colour which will lead to
241 the automatic creation of a wxMask object associated to the bitmap object.
242
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
292 @library{wxcore}
293 @category{gdi}
294
295 @stdobjects
296 ::wxNullImage
297
298 @see wxBitmap, wxInitAllImageHandlers(), wxPixelData
299 */
300 class wxImage : public wxObject
301 {
302 public:
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.
331 */
332 wxImage();
333
334 /**
335 Creates an image with the given size and clears it if requested.
336
337 Does not create an alpha channel.
338
339 @param width
340 Specifies the width of the image.
341 @param height
342 Specifies the height of the image.
343 @param clear
344 If @true, initialize the image to black.
345 */
346 wxImage(int width, int height, bool clear = true);
347
348 /**
349 Creates an image from data in memory. If @a static_data is @false
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.
352
353 @param width
354 Specifies the width of the image.
355 @param height
356 Specifies the height of the image.
357 @param data
358 A pointer to RGB data
359 @param static_data
360 Indicates if the data should be free'd after use
361
362 */
363 wxImage(int width, int height, unsigned char* data, bool static_data = false);
364
365 /**
366 Creates an image from data in memory. If @a static_data is @false
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.
369
370 @param width
371 Specifies the width of the image.
372 @param height
373 Specifies the height of the image.
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
380
381 */
382 wxImage(int width, int height, unsigned char* data, unsigned char* alpha,
383 bool static_data = false );
384
385 /**
386 Creates an image from XPM data.
387
388 @param xpmData
389 A pointer to XPM image data.
390 */
391 wxImage(const char* const* xpmData);
392
393 /**
394 Creates an image from a file.
395
396 @param name
397 Name of the file from which to load the image.
398 @param type
399 May be one of the following:
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.
413 @param index
414 Index of the image to load in the case that the image file contains
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.
419
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
431
432 @see LoadFile()
433 */
434 wxImage(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1);
435
436 /**
437 Creates an image from a file using MIME-types to specify the type.
438
439 @param name
440 Name of the file from which to load the image.
441 @param mimetype
442 MIME type string (for example 'image/jpeg')
443 @param index
444 See description in wxImage(const wxString&, wxBitmapType, int) overload.
445 */
446 wxImage(const wxString& name, const wxString& mimetype, int index = -1);
447
448 /**
449 Creates an image from a stream.
450
451 @param stream
452 Opened input stream from which to load the image. Currently,
453 the stream must support seeking.
454 @param type
455 See description in wxImage(const wxString&, wxBitmapType, int) overload.
456 @param index
457 See description in wxImage(const wxString&, wxBitmapType, int) overload.
458 */
459 wxImage(wxInputStream& stream, wxBitmapType type = wxBITMAP_TYPE_ANY, int index = -1);
460
461 /**
462 Creates an image from a stream using MIME-types to specify the type.
463
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
470 See description in wxImage(const wxString&, wxBitmapType, int) overload.
471 */
472 wxImage(wxInputStream& stream, const wxString& mimetype, int index = -1);
473
474
475 /**
476 Destructor.
477
478 See @ref overview_refcount_destruct "reference-counted object destruction"
479 for more info.
480 */
481 virtual ~wxImage();
482
483 /**
484 Register an image handler.
485 See @ref image_handlers for a list of the available handlers.
486 */
487 static void AddHandler(wxImageHandler* handler);
488
489 /**
490 Blurs the image in both horizontal and vertical directions by the
491 specified pixel @a blurRadius. This should not be used when using
492 a single mask colour for transparency.
493
494 @see BlurHorizontal(), BlurVertical()
495 */
496 wxImage Blur(int blurRadius) const;
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.
501
502 @see Blur(), BlurVertical()
503 */
504 wxImage BlurHorizontal(int blurRadius) const;
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.
509
510 @see Blur(), BlurHorizontal()
511 */
512 wxImage BlurVertical(int blurRadius) const;
513
514 /**
515 Returns @true if the current image handlers can read this file
516 */
517 static bool CanRead(const wxString& filename);
518
519 /**
520 Deletes all image handlers.
521 This function is called by wxWidgets on exit.
522 */
523 static void CleanUpHandlers();
524
525 /**
526 Computes the histogram of the image. @a histogram is a reference to
527 wxImageHistogram object. wxImageHistogram is a specialization of
528 wxHashMap "template" and is defined as follows:
529
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
544 @return Returns number of colours in the histogram.
545 */
546 unsigned long ComputeHistogram(wxImageHistogram& histogram) const;
547
548 //@{
549 /**
550 If the image has alpha channel, this method converts it to mask.
551
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.
555
556 The mask colour is chosen automatically using
557 FindFirstUnusedColour() by this function, see the overload below if you
558 this is not appropriate.
559
560 @return @false if FindFirstUnusedColour returns @false, @true otherwise.
561 */
562 bool ConvertAlphaToMask(unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD);
563
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 */
587 void ConvertAlphaToMask(unsigned char mr, unsigned char mg, unsigned char mb,
588 unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD);
589 //@}
590
591 /**
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).
598 */
599 wxImage ConvertToGreyscale(double lr = 0.299, double lg = 0.587, double lb = 1.114) const;
600
601 /**
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.
606 */
607 wxImage ConvertToMono(unsigned char r, unsigned char g, unsigned char b) const;
608
609 /**
610 Returns an identical copy of the image.
611 */
612 wxImage Copy() const;
613
614 /**
615 Creates a fresh image.
616
617 If @a clear is @true, the new image will be initialized to black.
618 Otherwise, the image data will be uninitialized.
619
620 @param width
621 The width of the image in pixels.
622 @param height
623 The height of the image in pixels.
624 @param clear
625 If @true, initialize the image data with zeroes.
626
627 @return @true if the call succeeded, @false otherwise.
628 */
629 bool Create(int width, int height, bool clear = true);
630
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
639 /**
640 Destroys the image data.
641 */
642 void Destroy();
643
644 /**
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.
655
656 @return Returns @false if there is no unused colour left, @true on success.
657
658 @note
659 This method involves computing the histogram, which is a
660 computationally intensive operation.
661 */
662 bool FindFirstUnusedColour(unsigned char* r, unsigned char* g,
663 unsigned char* b, unsigned char startR = 1,
664 unsigned char startG = 0,
665 unsigned char startB = 0) const;
666
667 /**
668 Finds the handler with the given name.
669
670 @param name
671 The handler name.
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
682 @param extension
683 The file extension, such as "bmp".
684 @param imageType
685 The image type; one of the ::wxBitmapType values.
686
687 @return A pointer to the handler if found, @NULL otherwise.
688
689 @see wxImageHandler
690 */
691 static wxImageHandler* FindHandler(const wxString& extension,
692 wxBitmapType imageType);
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 */
704 static wxImageHandler* FindHandler(wxBitmapType imageType);
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 */
716 static wxImageHandler* FindHandlerMime(const wxString& mimetype);
717
718 /**
719 Return alpha value at given pixel location.
720 */
721 unsigned char GetAlpha(int x, int y) const;
722
723 /**
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
727 does have it, this pointer may be used to directly manipulate the alpha values
728 which are stored as the RGB ones.
729 */
730 unsigned char* GetAlpha() const;
731
732 /**
733 Returns the blue intensity at the given coordinate.
734 */
735 unsigned char GetBlue(int x, int y) const;
736
737 /**
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().
748 */
749 unsigned char* GetData() const;
750
751 /**
752 Returns the green intensity at the given coordinate.
753 */
754 unsigned char GetGreen(int x, int y) const;
755
756 /**
757 Returns the static list of image format handlers.
758
759 @see wxImageHandler
760 */
761 static wxList& GetHandlers();
762
763 /**
764 Gets the height of the image in pixels.
765
766 @see GetWidth(), GetSize()
767 */
768 int GetHeight() const;
769
770 //@{
771 /**
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.
795
796 @return Number of available images. For most image handlers, this is 1
797 (exceptions are TIFF and ICO formats).
798 */
799 static int GetImageCount(const wxString& filename,
800 wxBitmapType type = wxBITMAP_TYPE_ANY);
801 static int GetImageCount(wxInputStream& stream,
802 wxBitmapType type = wxBITMAP_TYPE_ANY);
803 //@}
804
805 /**
806 Iterates all registered wxImageHandler objects, and returns a string containing
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
818
819 @see wxImageHandler
820 */
821 static wxString GetImageExtWildcard();
822
823 /**
824 Gets the blue value of the mask colour.
825 */
826 unsigned char GetMaskBlue() const;
827
828 /**
829 Gets the green value of the mask colour.
830 */
831 unsigned char GetMaskGreen() const;
832
833 /**
834 Gets the red value of the mask colour.
835 */
836 unsigned char GetMaskRed() const;
837
838 /**
839 Gets a user-defined string-valued option.
840
841 Currently the only defined string option is
842 @li @c wxIMAGE_OPTION_FILENAME: The name of the file from which the image
843 was loaded.
844
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.
850
851 @see SetOption(), GetOptionInt(), HasOption()
852 */
853 wxString GetOption(const wxString& name) const;
854
855 /**
856 Gets a user-defined integer-valued option.
857
858 The function is case-insensitive to @a name.
859 If the given option is not present, the function returns 0.
860 Use HasOption() is 0 is a possibly valid value for the option.
861
862 Generic options:
863 @li @c wxIMAGE_OPTION_MAX_WIDTH and @c wxIMAGE_OPTION_MAX_HEIGHT: If either
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
876 @li @c wxIMAGE_OPTION_QUALITY: JPEG quality used when saving. This is an
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
881 @li @c wxIMAGE_OPTION_RESOLUTIONUNIT: The value of this option determines
882 whether the resolution of the image is specified in centimetres or
883 inches, see wxImageResolution enum elements.
884
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
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:
896 @li @c wxIMAGE_OPTION_PNG_FORMAT: Format for saving a PNG file, see
897 wxImagePNGType for the supported values.
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.
918
919 @param name
920 The name of the option, case-insensitive.
921 @return
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()
926 */
927 int GetOptionInt(const wxString& name) const;
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 */
933 bool GetOrFindMaskColour(unsigned char* r, unsigned char* g,
934 unsigned char* b) const;
935
936 /**
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).
943 */
944 const wxPalette& GetPalette() const;
945
946 /**
947 Returns the red intensity at the given coordinate.
948 */
949 unsigned char GetRed(int x, int y) const;
950
951 /**
952 Returns a sub image of the current one as long as the rect belongs entirely
953 to the image.
954 */
955 wxImage GetSubImage(const wxRect& rect) const;
956
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
966 /**
967 Gets the type of image found by LoadFile() or specified with SaveFile().
968
969 @since 2.9.0
970 */
971 wxBitmapType GetType() const;
972
973 /**
974 Gets the width of the image in pixels.
975
976 @see GetHeight(), GetSize()
977 */
978 int GetWidth() const;
979
980 /**
981 Converts a color in HSV color space to RGB color space.
982 */
983 static wxImage::RGBValue HSVtoRGB(const wxImage::HSVValue& hsv);
984
985 /**
986 Returns @true if this image has alpha channel, @false otherwise.
987
988 @see GetAlpha(), SetAlpha()
989 */
990 bool HasAlpha() const;
991
992 /**
993 Returns @true if there is a mask active, @false otherwise.
994 */
995 bool HasMask() const;
996
997 /**
998 Returns @true if the given option is present.
999 The function is case-insensitive to @a name.
1000
1001 The lists of the currently supported options are in GetOption() and
1002 GetOptionInt() function docs.
1003
1004 @see SetOption(), GetOption(), GetOptionInt()
1005 */
1006 bool HasOption(const wxString& name) const;
1007
1008 /**
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.
1015 */
1016 void InitAlpha();
1017
1018 /**
1019 Internal use only. Adds standard image format handlers.
1020 It only install wxBMPHandler for the time being, which is used by wxBitmap.
1021
1022 This function is called by wxWidgets on startup, and shouldn't be called by
1023 the user.
1024
1025 @see wxImageHandler, wxInitAllImageHandlers(), wxQuantize
1026 */
1027 static void InitStandardHandlers();
1028
1029 /**
1030 Adds a handler at the start of the static list of format handlers.
1031
1032 @param handler
1033 A new image format handler object. There is usually only one instance
1034 of a given handler class in an application session.
1035
1036 @see wxImageHandler
1037 */
1038 static void InsertHandler(wxImageHandler* handler);
1039
1040 /**
1041 Returns @true if image data is present.
1042 */
1043 bool IsOk() const;
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
1048 value of this pixel is strictly less than @a threshold.
1049 */
1050 bool IsTransparent(int x, int y,
1051 unsigned char threshold = wxIMAGE_ALPHA_THRESHOLD) const;
1052
1053 /**
1054 Loads an image from an input stream.
1055
1056 @param stream
1057 Opened input stream from which to load the image.
1058 Currently, the stream must support seeking.
1059 @param type
1060 May be one of the following:
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.
1074 @param index
1075 Index of the image to load in the case that the image file contains
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.
1080
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.
1084
1085 @remarks Depending on how wxWidgets has been configured, not all formats
1086 may be available.
1087
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
1095 @see SaveFile()
1096 */
1097 virtual bool LoadFile(wxInputStream& stream,
1098 wxBitmapType type = wxBITMAP_TYPE_ANY,
1099 int index = -1);
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 */
1112 virtual bool LoadFile(const wxString& name,
1113 wxBitmapType type = wxBITMAP_TYPE_ANY,
1114 int index = -1);
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 */
1127 virtual bool LoadFile(const wxString& name, const wxString& mimetype,
1128 int index = -1);
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 */
1142 virtual bool LoadFile(wxInputStream& stream, const wxString& mimetype,
1143 int index = -1);
1144
1145 /**
1146 Returns a mirrored copy of the image.
1147 The parameter @a horizontally indicates the orientation.
1148 */
1149 wxImage Mirror(bool horizontally = true) const;
1150
1151 /**
1152 Copy the data of the given @a image to the specified position in this image.
1153 */
1154 void Paste(const wxImage& image, int x, int y);
1155
1156 /**
1157 Converts a color in RGB color space to HSV color space.
1158 */
1159 static wxImage::HSVValue RGBtoHSV(const wxImage::RGBValue& rgb);
1160
1161 /**
1162 Finds the handler with the given name, and removes it.
1163 The handler is not deleted.
1164
1165 @param name
1166 The handler name.
1167
1168 @return @true if the handler was found and removed, @false otherwise.
1169
1170 @see wxImageHandler
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
1183 function,the image will have the given width and height.
1184
1185 For a description of the @a quality parameter, see the Scale() function.
1186 Returns the (modified) image itself.
1187
1188 @see Scale()
1189 */
1190 wxImage& Rescale(int width, int height,
1191 int quality = wxIMAGE_QUALITY_NORMAL);
1192
1193 /**
1194 Changes the size of the image in-place without scaling it by adding either a
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.
1205
1206 @see Size()
1207 */
1208 wxImage& Resize(const wxSize& size, const wxPoint& pos, int red = -1,
1209 int green = -1, int blue = -1);
1210
1211 /**
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
1219 Returns the rotated image, leaving this image intact.
1220 */
1221 wxImage Rotate(double angle, const wxPoint& rotationCentre,
1222 bool interpolating = true,
1223 wxPoint* offsetAfterRotation = NULL) const;
1224
1225 /**
1226 Returns a copy of the image rotated 90 degrees in the direction
1227 indicated by @a clockwise.
1228 */
1229 wxImage Rotate90(bool clockwise = true) const;
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
1234 corresponds to +360 degrees.
1235 */
1236 void RotateHue(double angle);
1237
1238 /**
1239 Saves an image in the given stream.
1240
1241 @param stream
1242 Opened output stream to save the image to.
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 */
1261 virtual bool SaveFile(wxOutputStream& stream,
1262 const wxString& mimetype) const;
1263
1264 /**
1265 Saves an image in the named file.
1266
1267 @param name
1268 Name of the file to save the image to.
1269 @param type
1270 Currently these types can be used:
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.
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).
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.
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.
1282 @li wxBITMAP_TYPE_CUR: Save a Windows cursor file (CUR).
1283 */
1284 virtual bool SaveFile(const wxString& name, wxBitmapType type) const;
1285
1286 /**
1287 Saves an image in the named file.
1288
1289 @param name
1290 Name of the file to save the image to.
1291 @param mimetype
1292 MIME type.
1293 */
1294 virtual bool SaveFile(const wxString& name, const wxString& mimetype) const;
1295
1296 /**
1297 Saves an image in the named file.
1298
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.
1303
1304 @param name
1305 Name of the file to save the image to.
1306 */
1307 virtual bool SaveFile(const wxString& name) const;
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 */
1317 virtual bool SaveFile(wxOutputStream& stream, wxBitmapType type) const;
1318
1319 /**
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
1335 this method you will most likely notice that it is a bit slower and in extreme
1336 cases it will be quite substantially slower as the bicubic algorithm has to process a
1337 lot of data.
1338
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.
1343
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
1360
1361 @see Rescale()
1362 */
1363 wxImage Scale(int width, int height,
1364 int quality = wxIMAGE_QUALITY_NORMAL) const;
1365
1366 /**
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.
1377 */
1378 void SetAlpha(unsigned char* alpha = NULL,
1379 bool static_data = false);
1380
1381 /**
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.
1385 */
1386 void SetAlpha(int x, int y, unsigned char alpha);
1387
1388 //@{
1389 /**
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
1396 The data must have been allocated with @c malloc(), @b NOT with
1397 @c operator new.
1398
1399 After this call the pointer to the data is owned by the wxImage object,
1400 that will be responsible for deleting it.
1401 Do not pass to this function a pointer obtained through GetData().
1402 */
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 //@}
1407
1408 /**
1409 Specifies whether there is a mask or not.
1410
1411 The area of the mask is determined by the current mask colour.
1412 */
1413 void SetMask(bool hasMask = true);
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 /**
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.
1434
1435 @return Returns @false if mask does not have same dimensions as the image
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.
1442 */
1443 bool SetMaskFromImage(const wxImage& mask, unsigned char mr,
1444 unsigned char mg,
1445 unsigned char mb);
1446
1447 //@{
1448 /**
1449 Sets a user-defined option. The function is case-insensitive to @a name.
1450
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).
1453
1454 The lists of the currently supported options are in GetOption() and
1455 GetOptionInt() function docs.
1456
1457 @see GetOption(), GetOptionInt(), HasOption()
1458 */
1459 void SetOption(const wxString& name, const wxString& value);
1460 void SetOption(const wxString& name, int value);
1461 //@}
1462
1463 /**
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).
1468 */
1469 void SetPalette(const wxPalette& palette);
1470
1471 /**
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.
1476 */
1477 void SetRGB(const wxRect& rect,
1478 unsigned char red,
1479 unsigned char green,
1480 unsigned char blue);
1481
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
1501 /**
1502 Returns a resized version of this image without scaling it by adding either a
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.
1513
1514 @see Resize()
1515 */
1516 wxImage Size(const wxSize& size, const wxPoint& pos, int red = -1,
1517 int green = -1, int blue = -1) const;
1518
1519 /**
1520 Assignment operator, using @ref overview_refcount "reference counting".
1521
1522 @param image
1523 Image to assign.
1524
1525 @return Returns 'this' object.
1526 */
1527 wxImage& operator=(const wxImage& image);
1528 };
1529
1530 /**
1531 An instance of an empty image without an alpha channel.
1532 */
1533 wxImage wxNullImage;
1534
1535
1536 // ============================================================================
1537 // Global functions/macros
1538 // ============================================================================
1539
1540 /** @addtogroup group_funcmacro_appinitterm */
1541 //@{
1542
1543 /**
1544 Initializes all available image handlers. For a list of available handlers,
1545 see wxImage.
1546 If you don't need/want all image handlers loaded
1547
1548 @see wxImage, wxImageHandler
1549
1550 @header{wx/image.h}
1551 */
1552 void wxInitAllImageHandlers();
1553
1554 //@}
1555