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