]>
git.saurik.com Git - wxWidgets.git/blob - interface/image.h
6062c08dcdd09ed54a6195c167ce8156188de7f5
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxImageHandler
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 This is the base class for implementing image file loading/saving, and image
15 It is used within wxImage and is not normally seen by the application.
17 If you wish to extend the capabilities of wxImage, derive a class from
19 and add the handler using wxImage::AddHandler in your
20 application initialisation.
25 @see wxImage, wxInitAllImageHandlers()
27 class wxImageHandler
: public wxObject
31 Default constructor. In your own default constructor, initialise the members
32 m_name, m_extension and m_type.
37 Destroys the wxImageHandler object.
42 Gets the file extension associated with this handler.
44 const wxString
GetExtension() const;
47 If the image file contains more than one image and the image handler is capable
48 of retrieving these individually, this function will return the number of
52 Opened input stream for reading image data. Currently, the stream must
55 @returns Number of available images. For most image handlers, this is 1
56 (exceptions are TIFF and ICO formats).
58 int GetImageCount(wxInputStream
& stream
);
61 Gets the MIME type associated with this handler.
63 const wxString
GetMimeType() const;
66 Gets the name of this handler.
68 const wxString
GetName() const;
71 Gets the image type associated with this handler.
76 Loads a image from a stream, putting the resulting data into @e image. If the
78 more than one image and the image handler is capable of retrieving these
79 individually, @e index
80 indicates which image to read from the stream.
83 The image object which is to be affected by this operation.
85 Opened input stream for reading image data.
87 If set to @true, errors reported by the image handler will produce
90 The index of the image in the file (starting from zero).
92 @returns @true if the operation succeeded, @false otherwise.
94 @see wxImage::LoadFile, wxImage::SaveFile, SaveFile()
96 bool LoadFile(wxImage
* image
, wxInputStream
& stream
,
97 bool verbose
= true, int index
= 0);
100 Saves a image in the output stream.
103 The image object which is to be affected by this operation.
105 Opened output stream for writing the data.
107 @returns @true if the operation succeeded, @false otherwise.
109 @see wxImage::LoadFile, wxImage::SaveFile, LoadFile()
111 bool SaveFile(wxImage
* image
, wxOutputStream
& stream
);
114 Sets the handler extension.
119 void SetExtension(const wxString
& extension
);
122 Sets the handler MIME type.
127 void SetMimeType(const wxString
& mimetype
);
130 Sets the handler name.
135 void SetName(const wxString
& name
);
144 This class encapsulates a platform-independent image. An image can be created
145 from data, or using wxBitmap::ConvertToImage. An image
146 can be loaded from a file in a variety of formats, and is extensible to new
148 via image format handlers. Functions are available to set and get image bits, so
149 it can be used for basic image manipulation.
151 A wxImage cannot (currently) be drawn directly to a wxDC. Instead,
152 a platform-specific wxBitmap object must be created from it using
153 the wxBitmap::wxBitmap(wxImage,int depth) constructor.
155 be drawn in a device context, using wxDC::DrawBitmap.
157 One colour value of the image may be used as a mask colour which will lead to
158 the automatic creation of a wxMask object associated to the bitmap object.
166 @see wxBitmap, wxInitAllImageHandlers(), wxPixelData
168 class wxImage
: public wxObject
173 Creates an image from data in memory. If static_data is false
174 then the wxImage will take ownership of the data and free it
175 afterwards. For this, it has to be allocated with @e malloc.
178 Specifies the width of the image.
180 Specifies the height of the image.
182 A pointer to RGB data
184 A pointer to alpha-channel data
186 Indicates if the data should be free'd after use
189 wxImage(int width
, int height
, unsigned char* data
, unsigned char* alpha
, bool static_data
= false );
190 wxImage(int width
, int height
, unsigned char* data
, bool static_data
= false);
194 Creates an image with the given size and clears it if requested.
195 Does not create an alpha channel.
198 Specifies the width of the image.
200 Specifies the height of the image.
202 Clear the image with zeros.
204 wxImage(int width
, int height
, bool clear
= true);
207 Creates an empty wxImage object. Does not create
213 Creates an image from XPM data.
216 A pointer to XPM image data.
218 wxImage(const char* const* xpmData
);
222 Name of the file from which to load the image.
224 Opened input stream from which to load the image. Currently,
225 the stream must support seeking.
227 May be one of the following:
228 @li wxBITMAP_TYPE_BMP: Load a Windows bitmap file.
229 @li wxBITMAP_TYPE_GIF: Load a GIF bitmap file.
230 @li wxBITMAP_TYPE_JPEG: Load a JPEG bitmap file.
231 @li wxBITMAP_TYPE_PNG: Load a PNG bitmap file.
232 @li wxBITMAP_TYPE_PCX: Load a PCX bitmap file.
233 @li wxBITMAP_TYPE_PNM: Load a PNM bitmap file.
234 @li wxBITMAP_TYPE_TIF: Load a TIFF bitmap file.
235 @li wxBITMAP_TYPE_TGA: Load a TGA bitmap file.
236 @li wxBITMAP_TYPE_XPM: Load a XPM bitmap file.
237 @li wxBITMAP_TYPE_ICO: Load a Windows icon file (ICO).
238 @li wxBITMAP_TYPE_CUR: Load a Windows cursor file (CUR).
239 @li wxBITMAP_TYPE_ANI: Load a Windows animated cursor file (ANI).
240 @li wxBITMAP_TYPE_ANY: Will try to autodetect the format.
243 MIME type string (for example 'image/jpeg')
245 Index of the image to load in the case that the image file contains
246 multiple images. This is only used by GIF, ICO and TIFF handlers.
247 The default value (-1) means "choose the default image" and is
248 interpreted as the first image (index=0) by the GIF and TIFF handler
249 and as the largest and most colourful one by the ICO handler.
251 @remarks Depending on how wxWidgets has been configured, not all formats
256 wxImage(const wxString
& name
, long type
= wxBITMAP_TYPE_ANY
, int index
= -1);
257 wxImage(const wxString
& name
, const wxString
& mimetype
, int index
= -1);
258 wxImage(wxInputStream
& stream
, long type
= wxBITMAP_TYPE_ANY
, int index
= -1);
259 wxImage(wxInputStream
& stream
, const wxString
& mimetype
, int index
= -1);
265 See @ref overview_refcountdestruct "reference-counted object destruction" for
272 returns @true if the current image handlers can read this file
274 static void AddHandler(wxImageHandler
* handler
);
275 See also
bool CanRead(const wxString
& filename
);
279 Blurs the image in both horizontal and vertical directions by the specified
281 @e blurRadius. This should not be used when using a single mask colour
284 @see @ref horzblur() BlurHorizontal, @ref vertblur() BlurVertical
286 wxImage
Blur(int blurRadius
);
289 Blurs the image in the horizontal direction only. This should not be used
290 when using a single mask colour for transparency.
292 @see Blur(), @ref vertblur() BlurVertical
294 wxImage
BlurHorizontal(int blurRadius
);
297 Blurs the image in the vertical direction only. This should not be used
298 when using a single mask colour for transparency.
300 @see Blur(), @ref horzblur() BlurHorizontal
302 wxImage
BlurVertical(int blurRadius
);
305 Deletes all image handlers.
306 This function is called by wxWidgets on exit.
308 static void CleanUpHandlers();
311 Computes the histogram of the image. @a histogram is a reference to
312 wxImageHistogram object. wxImageHistogram is a specialization of
313 wxHashMap "template" and is defined as follows:
315 @returns Returns number of colours in the histogram.
317 unsigned long ComputeHistogram(wxImageHistogram
& histogram
) const;
320 If the image has alpha channel, this method converts it to mask. All pixels
321 with alpha value less than @a threshold are replaced with mask colour
322 and the alpha channel is removed. Mask colour is chosen automatically using
323 FindFirstUnusedColour().
324 If the image image doesn't have alpha channel,
325 ConvertAlphaToMask does nothing.
327 @returns @false if FindFirstUnusedColour returns @false, @true otherwise.
329 bool ConvertAlphaToMask(unsigned char threshold
= 128);
332 Deprecated, use equivalent @ref wxBitmap::ctor "wxBitmap constructor"
333 (which takes wxImage and depth as its arguments) instead.
335 wxBitmap
ConvertToBitmap() const;
338 Returns a greyscale version of the image. The returned image uses the luminance
339 component of the original to calculate the greyscale. Defaults to using
340 ITU-T BT.601 when converting to YUV, where every pixel equals
341 (R * @e lr) + (G * @e lg) + (B * @e lb).
343 wxImage
ConvertToGreyscale(double lr
= 0.299, double lg
= 0.587,
344 double lb
= 0.114) const;
347 Returns monochromatic version of the image. The returned image has white
348 colour where the original has @e (r,g,b) colour and black colour
351 wxImage
ConvertToMono(unsigned char r
, unsigned char g
,
352 unsigned char b
) const;
355 Returns an identical copy of the image.
357 wxImage
Copy() const;
360 Creates a fresh image. If @a clear is @true, the new image will be initialized
362 Otherwise, the image data will be uninitialized.
365 The width of the image in pixels.
367 The height of the image in pixels.
369 @returns @true if the call succeeded, @false otherwise.
371 bool Create(int width
, int height
, bool clear
= true);
374 Destroys the image data.
380 Pointers to variables to save the colour.
381 @param startR,startG,startB
382 Initial values of the colour. Returned colour
383 will have RGB values equal to or greater than these.
385 @returns Returns @false if there is no unused colour left, @true on success.
387 bool FindFirstUnusedColour(unsigned char* r
, unsigned char* g
,
389 unsigned char startR
= 1,
390 unsigned char startG
= 0,
391 unsigned char startB
= 0);
395 Finds the handler associated with the given MIME type.
400 The file extension, such as "bmp".
402 The image type, such as wxBITMAP_TYPE_BMP.
406 @returns A pointer to the handler if found, @NULL otherwise.
410 static wxImageHandler
* FindHandler(const wxString
& name
);
411 static wxImageHandler
* FindHandler(const wxString
& extension
,
413 static wxImageHandler
* FindHandler(long imageType
);
414 static wxImageHandler
* FindHandlerMime(const wxString
& mimetype
);
419 Returns pointer to the array storing the alpha values for this image. This
420 pointer is @NULL for the images without the alpha channel. If the image
421 does have it, this pointer may be used to directly manipulate the alpha values
422 which are stored as the @ref getdata() RGB ones.
424 unsigned char GetAlpha(int x
, int y
) const;
425 const unsigned char * GetAlpha() const;
429 Returns the blue intensity at the given coordinate.
431 unsigned char GetBlue(int x
, int y
) const;
434 Returns the image data as an array. This is most often used when doing
435 direct image manipulation. The return value points to an array of
436 characters in RGBRGBRGB... format in the top-to-bottom, left-to-right
437 order, that is the first RGB triplet corresponds to the pixel first pixel of
438 the first row, the second one --- to the second pixel of the first row and so
439 on until the end of the first row, with second row following after it and so
441 You should not delete the returned pointer nor pass it to
444 unsigned char* GetData() const;
447 Returns the green intensity at the given coordinate.
449 unsigned char GetGreen(int x
, int y
) const;
452 Returns the static list of image format handlers.
456 static wxList
GetHandlers();
459 Gets the height of the image in pixels.
461 int GetHeight() const;
465 If the image file contains more than one image and the image handler is capable
466 of retrieving these individually, this function will return the number of
470 Name of the file to query.
472 Opened input stream with image data. Currently, the stream must
475 May be one of the following:
476 @li wxBITMAP_TYPE_BMP: Load a Windows bitmap file.
477 @li wxBITMAP_TYPE_GIF: Load a GIF bitmap file.
478 @li wxBITMAP_TYPE_JPEG: Load a JPEG bitmap file.
479 @li wxBITMAP_TYPE_PNG: Load a PNG bitmap file.
480 @li wxBITMAP_TYPE_PCX: Load a PCX bitmap file.
481 @li wxBITMAP_TYPE_PNM: Load a PNM bitmap file.
482 @li wxBITMAP_TYPE_TIF: Load a TIFF bitmap file.
483 @li wxBITMAP_TYPE_TGA: Load a TGA bitmap file.
484 @li wxBITMAP_TYPE_XPM: Load a XPM bitmap file.
485 @li wxBITMAP_TYPE_ICO: Load a Windows icon file (ICO).
486 @li wxBITMAP_TYPE_CUR: Load a Windows cursor file (CUR).
487 @li wxBITMAP_TYPE_ANI: Load a Windows animated cursor file (ANI).
488 @li wxBITMAP_TYPE_ANY: Will try to autodetect the format.
490 @returns Number of available images. For most image handlers, this is 1
491 (exceptions are TIFF and ICO formats).
493 static int GetImageCount(const wxString
& filename
,
494 long type
= wxBITMAP_TYPE_ANY
);
495 static int GetImageCount(wxInputStream
& stream
,
496 long type
= wxBITMAP_TYPE_ANY
);
500 Iterates all registered wxImageHandler objects, and returns a string containing
502 suitable for passing to file open/save dialog boxes.
504 @returns The format of the returned string is
505 "(*.ext1;*.ext2)|*.ext1;*.ext2".
509 static wxString
GetImageExtWildcard();
512 Gets the blue value of the mask colour.
514 unsigned char GetMaskBlue() const;
517 Gets the green value of the mask colour.
519 unsigned char GetMaskGreen() const;
522 Gets the red value of the mask colour.
524 unsigned char GetMaskRed() const;
527 Gets a user-defined option. The function is case-insensitive to @e name.
528 For example, when saving as a JPEG file, the option @b quality is
529 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
531 @see SetOption(), GetOptionInt(), HasOption()
533 wxString
GetOption(const wxString
& name
) const;
536 Gets a user-defined option as an integer. The function is case-insensitive
537 to @e name. If the given option is not present, the function returns 0.
538 Use HasOption() is 0 is a possibly valid value for the option.
539 Options for wxPNGHandler
540 @li wxIMAGE_OPTION_PNG_FORMAT: Format for saving a PNG file.
541 @li wxIMAGE_OPTION_PNG_BITDEPTH: Bit depth for every channel (R/G/B/A).
543 Supported values for wxIMAGE_OPTION_PNG_FORMAT:
544 @li wxPNG_TYPE_COLOUR: Stores RGB image.
545 @li wxPNG_TYPE_GREY: Stores grey image, converts from RGB.
546 @li wxPNG_TYPE_GREY_RED: Stores grey image, uses red value as grey.
548 @see SetOption(), GetOption()
550 int GetOptionInt(const wxString
& name
) const;
553 Get the current mask colour or find a suitable unused colour that could be
554 used as a mask colour. Returns @true if the image currently has a mask.
556 bool GetOrFindMaskColour(unsigned char r
, unsigned char g
,
557 unsigned char b
) const;
560 Returns the palette associated with the image. Currently the palette is only
561 used when converting to wxBitmap under Windows. Some of the wxImage handlers
562 have been modified to set the palette if one exists in the image file (usually
563 256 or less colour images in GIF or PNG format).
565 const wxPalette
GetPalette() const;
568 Returns the red intensity at the given coordinate.
570 unsigned char GetRed(int x
, int y
) const;
573 Returns a sub image of the current one as long as the rect belongs entirely to
576 wxImage
GetSubImage(const wxRect
& rect
) const;
579 Gets the width of the image in pixels.
583 int GetWidth() const;
586 Constructor for HSVValue, an object that contains values for hue, saturation
588 represent the value of a color. It is used by HSVtoRGB()
589 and RGBtoHSV(), which
590 converts between HSV color space and RGB color space.
592 HSVValue(double h
= 0.0, double s
= 0.0, double v
= 0.0);
595 Converts a color in HSV color space to RGB color space.
597 #define wxImage::RGBValue HSVtoRGB(const HSVValue& hsv) /* implementation is private */
600 Returns @true if this image has alpha channel, @false otherwise.
602 @see GetAlpha(), SetAlpha()
604 bool HasAlpha() const;
607 Returns @true if there is a mask active, @false otherwise.
609 bool HasMask() const;
612 Returns @true if the given option is present. The function is case-insensitive
615 @see SetOption(), GetOption(), GetOptionInt()
617 bool HasOption(const wxString
& name
) const;
620 Initializes the image alpha channel data. It is an error to call it
621 if the image already has alpha data. If it doesn't, alpha data will be
622 by default initialized to all pixels being fully opaque. But if the image has a
623 a mask colour, all mask pixels will be completely transparent.
628 Internal use only. Adds standard image format handlers. It only install BMP
629 for the time being, which is used by wxBitmap.
630 This function is called by wxWidgets on startup, and shouldn't be called by
633 @see wxImageHandler, wxInitAllImageHandlers(), wxQuantize
635 static void InitStandardHandlers();
638 Adds a handler at the start of the static list of format handlers.
641 A new image format handler object. There is usually only one instance
642 of a given handler class in an application session.
646 static void InsertHandler(wxImageHandler
* handler
);
649 Returns @true if image data is present.
654 Returns @true if the given pixel is transparent, i.e. either has the mask
655 colour if this image has a mask or if this image has alpha channel and alpha
656 value of this pixel is strictly less than @e threshold.
658 bool IsTransparent(int x
, int y
, unsigned char threshold
= 128) const;
662 Loads an image from an input stream.
665 Name of the file from which to load the image.
667 Opened input stream from which to load the image. Currently, the
668 stream must support seeking.
670 May be one of the following:
671 @li wxBITMAP_TYPE_BMP: Load a Windows bitmap file.
672 @li wxBITMAP_TYPE_GIF: Load a GIF bitmap file.
673 @li wxBITMAP_TYPE_JPEG: Load a JPEG bitmap file.
674 @li wxBITMAP_TYPE_PNG: Load a PNG bitmap file.
675 @li wxBITMAP_TYPE_PCX: Load a PCX bitmap file.
676 @li wxBITMAP_TYPE_PNM: Load a PNM bitmap file.
677 @li wxBITMAP_TYPE_TIF: Load a TIFF bitmap file.
678 @li wxBITMAP_TYPE_TGA: Load a TGA bitmap file.
679 @li wxBITMAP_TYPE_XPM: Load a XPM bitmap file.
680 @li wxBITMAP_TYPE_ICO: Load a Windows icon file (ICO).
681 @li wxBITMAP_TYPE_CUR: Load a Windows cursor file (CUR).
682 @li wxBITMAP_TYPE_ANI: Load a Windows animated cursor file (ANI).
683 @li wxBITMAP_TYPE_ANY: Will try to autodetect the format.
685 MIME type string (for example 'image/jpeg')
687 Index of the image to load in the case that the image file contains
688 multiple images. This is only used by GIF, ICO and TIFF handlers.
689 The default value (-1) means "choose the default image" and is
690 interpreted as the first image (index=0) by the GIF and TIFF handler
691 and as the largest and most colourful one by the ICO handler.
693 @returns @true if the operation succeeded, @false otherwise. If the
694 optional index parameter is out of range, @false is
695 returned and a call to wxLogError() takes place.
697 @remarks Depending on how wxWidgets has been configured, not all formats
702 bool LoadFile(const wxString
& name
,
703 long type
= wxBITMAP_TYPE_ANY
,
705 bool LoadFile(const wxString
& name
, const wxString
& mimetype
,
707 bool LoadFile(wxInputStream
& stream
, long type
,
709 bool LoadFile(wxInputStream
& stream
,
710 const wxString
& mimetype
,
715 Returns a mirrored copy of the image. The parameter @e horizontally
716 indicates the orientation.
718 wxImage
Mirror(bool horizontally
= true) const;
721 Copy the data of the given @a image to the specified position in this image.
723 void Paste(const wxImage
& image
, int x
, int y
);
726 Constructor for RGBValue, an object that contains values for red, green and
728 represent the value of a color. It is used by HSVtoRGB()
729 and RGBtoHSV(), which
730 converts between HSV color space and RGB color space.
732 RGBValue(unsigned char r
= 0, unsigned char g
= 0,
733 unsigned char b
= 0);
736 Converts a color in RGB color space to HSV color space.
738 #define wxImage::HSVValue RGBtoHSV(const RGBValue& rgb) /* implementation is private */
741 Finds the handler with the given name, and removes it. The handler
747 @returns @true if the handler was found and removed, @false otherwise.
751 static bool RemoveHandler(const wxString
& name
);
754 Replaces the colour specified by @e r1,g1,b1 by the colour @e r2,g2,b2.
756 void Replace(unsigned char r1
, unsigned char g1
,
757 unsigned char b1
, unsigned char r2
,
758 unsigned char g2
, unsigned char b2
);
761 Changes the size of the image in-place by scaling it: after a call to this
763 the image will have the given width and height.
764 For a description of the @a quality parameter, see the Scale() function.
765 Returns the (modified) image itself.
769 wxImage
Rescale(int width
, int height
,
770 int quality
= wxIMAGE_QUALITY_NORMAL
);
773 Changes the size of the image in-place without scaling it by adding either a
775 with the given colour or cropping as necessary. The image is pasted into a new
776 image with the given @a size and background colour at the position @e pos
777 relative to the upper left of the new image. If @a red = green = blue = -1
778 then use either the current mask colour if set or find, use, and set a
779 suitable mask colour for any newly exposed areas.
780 Returns the (modified) image itself.
784 wxImage
Resize(const wxSize
& size
, const wxPoint pos
,
785 int red
= -1, int green
= -1,
789 Rotates the image about the given point, by @a angle radians. Passing @true
790 to @a interpolating results in better image quality, but is slower. If the
791 image has a mask, then the mask colour is used for the uncovered pixels in the
792 rotated image background. Else, black (rgb 0, 0, 0) will be used.
793 Returns the rotated image, leaving this image intact.
795 wxImage
Rotate(double angle
, const wxPoint
& rotationCentre
,
796 bool interpolating
= true,
797 wxPoint
* offsetAfterRotation
= NULL
);
800 Returns a copy of the image rotated 90 degrees in the direction
801 indicated by @e clockwise.
803 wxImage
Rotate90(bool clockwise
= true) const;
806 Rotates the hue of each pixel in the image by @e angle, which is a double in
807 the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0
811 void RotateHue(double angle
);
815 Saves an image in the given stream.
818 Name of the file to save the image to.
820 Opened output stream to save the image to.
822 Currently these types can be used:
823 @li wxBITMAP_TYPE_BMP: Save a BMP image file.
824 @li wxBITMAP_TYPE_JPEG: Save a JPEG image file.
825 @li wxBITMAP_TYPE_PNG: Save a PNG image file.
826 @li wxBITMAP_TYPE_PCX: Save a PCX image file (tries to save as 8-bit if possible,
827 falls back to 24-bit otherwise).
828 @li wxBITMAP_TYPE_PNM: Save a PNM image file (as raw RGB always).
829 @li wxBITMAP_TYPE_TIFF: Save a TIFF image file.
830 @li wxBITMAP_TYPE_XPM: Save a XPM image file.
831 @li wxBITMAP_TYPE_ICO: Save a Windows icon file (ICO) (the size may
832 be up to 255 wide by 127 high. A single image is saved in 8 colors
833 at the size supplied).
834 @li wxBITMAP_TYPE_CUR: Save a Windows cursor file (CUR).
838 @returns @true if the operation succeeded, @false otherwise.
840 @remarks Depending on how wxWidgets has been configured, not all formats
845 bool SaveFile(const wxString
& name
, int type
) const;
846 const bool SaveFile(const wxString
& name
,
847 const wxString
& mimetype
) const;
848 const bool SaveFile(const wxString
& name
) const;
849 const bool SaveFile(wxOutputStream
& stream
, int type
) const;
850 const bool SaveFile(wxOutputStream
& stream
,
851 const wxString
& mimetype
) const;
855 Returns a scaled version of the image. This is also useful for
856 scaling bitmaps in general as the only other way to scale bitmaps
857 is to blit a wxMemoryDC into another wxMemoryDC.
858 It should be noted that although using wxIMAGE_QUALITY_HIGH produces much nicer
859 looking results it is a slower method. Downsampling will use the box averaging
861 which seems to operate very fast. If you are upsampling larger images using
862 this method you will most likely notice that it is a bit slower and in extreme
864 it will be quite substantially slower as the bicubic algorithm has to process a
867 It should also be noted that the high quality scaling may not work as expected
868 when using a single mask colour for transparency, as the scaling will blur the
869 image and will therefore remove the mask partially. Using the alpha channel
874 Determines what method to use for resampling the image.
876 Can be one of the following:
877 @li wxIMAGE_QUALITY_NORMAL: Uses the normal default scaling method of
879 @li wxIMAGE_QUALITY_HIGH: Uses bicubic and box averaging resampling
880 methods for upsampling and downsampling respectively
884 wxImage
Scale(int width
, int height
,
885 int quality
= wxIMAGE_QUALITY_NORMAL
) const;
889 Sets the alpha value for the given pixel. This function should only be called
890 if the image has alpha channel data, use HasAlpha() to
893 void SetAlpha(unsigned char* alpha
= NULL
,
894 bool static_data
= false);
895 void SetAlpha(int x
, int y
, unsigned char alpha
);
899 Sets the image data without performing checks. The data given must have
900 the size (width*height*3) or results will be unexpected. Don't use this
901 method if you aren't sure you know what you are doing.
902 The data must have been allocated with @c malloc(), @b NOT with
904 After this call the pointer to the data is owned by the wxImage object,
905 that will be responsible for deleting it.
906 Do not pass to this function a pointer obtained through
909 void SetData(unsigned char* data
);
912 Specifies whether there is a mask or not. The area of the mask is determined by
913 the current mask colour.
915 void SetMask(bool hasMask
= true);
918 Sets the mask colour for this image (and tells the image to use the mask).
920 void SetMaskColour(unsigned char red
, unsigned char green
,
925 The mask image to extract mask shape from. Must have same dimensions as the
928 RGB value of pixels in mask that will be used to create the mask.
930 @returns Returns @false if mask does not have same dimensions as the image
931 or if there is no unused colour left. Returns @true if
932 the mask was successfully applied.
934 bool SetMaskFromImage(const wxImage
& mask
, unsigned char mr
,
940 Sets a user-defined option. The function is case-insensitive to @e name.
941 For example, when saving as a JPEG file, the option @b quality is
942 used, which is a number between 0 and 100 (0 is terrible, 100 is very good).
944 @see GetOption(), GetOptionInt(), HasOption()
946 void SetOption(const wxString
& name
, const wxString
& value
);
947 void SetOption(const wxString
& name
, int value
);
951 Associates a palette with the image. The palette may be used when converting
952 wxImage to wxBitmap (MSW only at present) or in file save operations (none as
955 void SetPalette(const wxPalette
& palette
);
958 Sets the colour of the pixels within the given rectangle. This routine performs
959 bounds-checks for the coordinate so it can be considered a safe way to
963 void SetRGB(wxRect
& rect
, unsigned char red
,
968 Returns a resized version of this image without scaling it by adding either a
970 with the given colour or cropping as necessary. The image is pasted into a new
971 image with the given @a size and background colour at the position @e pos
972 relative to the upper left of the new image. If @a red = green = blue = -1
973 then the areas of the larger image not covered by this image are made
974 transparent by filling them with the image mask colour (which will be allocated
975 automatically if it isn't currently set). Otherwise, the areas will be filled
976 with the colour with the specified RGB components.
980 wxImage
Size(const wxSize
& size
, const wxPoint pos
, int red
= -1,
981 int green
= -1, int blue
= -1) const;
984 Assignment operator, using @ref overview_trefcount "reference counting".
989 @returns Returns 'this' object.
991 wxImage
operator =(const wxImage
& image
);
1000 // ============================================================================
1001 // Global functions/macros
1002 // ============================================================================
1004 /** @ingroup group_funcmacro_appinitterm */
1008 Initializes all available image handlers. For a list of available handlers,
1011 @see wxImage, wxImageHandler
1015 void wxInitAllImageHandlers();