\wxheading{Available image handlers}
The following image handlers are available. {\bf wxBMPHandler} is always
-installed by default. To use other image formats, install the appropiate
+installed by default. To use other image formats, install the appropriate
handler with \helpref{wxImage::AddHandler}{wximageaddhandler} or
\helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}.
\twocolwidtha{5cm}%
\begin{twocollist}
-\twocolitem{\indexit{wxBMPHandler}}{Only for loading, always installed.}
+\twocolitem{\indexit{wxBMPHandler}}{For loading and saving, always installed.}
\twocolitem{\indexit{wxPNGHandler}}{For loading and saving.}
\twocolitem{\indexit{wxJPEGHandler}}{For loading and saving.}
\twocolitem{\indexit{wxGIFHandler}}{Only for loading, due to legal issues.}
\twocolitem{\indexit{wxPCXHandler}}{For loading and saving (see below).}
\twocolitem{\indexit{wxPNMHandler}}{For loading and saving (see below).}
\twocolitem{\indexit{wxTIFFHandler}}{For loading and saving.}
+\twocolitem{\indexit{wxIFFHandler}}{For loading only.}
\twocolitem{\indexit{wxXPMHandler}}{For loading and saving.}
\twocolitem{\indexit{wxICOHandler}}{For loading and saving.}
\twocolitem{\indexit{wxCURHandler}}{For loading and saving.}
+\twocolitem{\indexit{wxANIHandler}}{For loading only.}
\end{twocollist}
When saving in PCX format, {\bf wxPCXHandler} will count the number of
\twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
\twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
\twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
+\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
\twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
\end{twocollist}}
\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
\docparam{index}{Index of the image to load in the case that the image file contains multiple images.
-This is only used by ICO and TIFF handlers. The default value (-1) means
+This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
"choose the default image" and is interpreted as the first image (index=0) by
-the TIFF handler and as the largest and most colourful one by the ICO handler.}
+the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
\wxheading{Remarks}
Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
hotspot for loaded cursor file:
\begin{verbatim}
- int hotspot_x = image.GetOptionInt(wxCUR_HOTSPOT_X);
- int hotspot_y = image.GetOptionInt(wxCUR_HOTSPOT_Y);
+ int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
+ int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
\end{verbatim}
\helpref{wxImageHandler}{wximagehandler}
+\func{bool}{CanRead}{\param{const wxString\&}{ filename}}
+
+returns TRUE if the current image handlers can read this file
+
\pythonnote{In wxPython this static method is named {\tt wxImage\_AddHandler}.}
\membersection{wxImage::CleanUpHandlers}
This function is called by wxWindows on exit.
+\membersection{wxImage::ComputeHistogram}\label{wximagecomputehistogram}
+
+\constfunc{unsigned long}{ComputeHistogram}{\param{wxImageHistogram\& }{histogram}}
+
+Computes the histogram of the image. {\it histogram} is a reference to
+wxImageHistogram object. wxImageHistogram is a specialization of
+\helpref{wxHashMap}{wxhashmap} "template" and is defined as follows:
+
+\begin{verbatim}
+class WXDLLEXPORT wxImageHistogramEntry
+{
+public:
+ wxImageHistogramEntry() : index(0), value(0) {}
+ unsigned long index;
+ unsigned long value;
+};
+
+WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry,
+ wxIntegerHash, wxIntegerEqual,
+ wxImageHistogram);
+\end{verbatim}
+
+\wxheading{Return value}
+
+Returns number of colours in the histogram.
+
\membersection{wxImage::ConvertToBitmap}\label{wximageconverttobitmap}
\constfunc{wxBitmap}{ConvertToBitmap}{\void}
Returns the image data as an array. This is most often used when doing
direct image manipulation. The return value points to an array of
-chararcters in RGBGBRGB... format.
+characters in RGBRGBRGB$\ldots$ format.
+
+You should not delete the returned pointer nor pass it to
+\helpref{wxImage::SetData}{wximagesetdata}.
\membersection{wxImage::GetGreen}\label{wximagegetgreen}
\twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.}
\twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
\twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
+\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
\twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
\end{twocollist}}
\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).}
\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).}
+\twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).}
\twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.}
\end{twocollist}}
\docparam{mimetype}{MIME type string (for example 'image/jpeg')}
\docparam{index}{Index of the image to load in the case that the image file contains multiple images.
-This is only used by ICO and TIFF handlers. The default value (-1) means
+This is only used by GIF, ICO and TIFF handlers. The default value (-1) means
"choose the default image" and is interpreted as the first image (index=0) by
-the TIFF handler and as the largest and most colourful one by the ICO handler.}
+the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.}
\wxheading{Remarks}
Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the
hotspot for loaded cursor file:
\begin{verbatim}
- int hotspot_x = image.GetOptionInt(wxCUR_HOTSPOT_X);
- int hotspot_y = image.GetOptionInt(wxCUR_HOTSPOT_Y);
+ int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
+ int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
\end{verbatim}
\wxheading{Return value}
-TRUE if the operation succeeded, FALSE otherwise.
+TRUE if the operation succeeded, FALSE otherwise. If the optional index parameter is out of range,
+FALSE is returned and a call to wxLogError() takes place.
\wxheading{See also}
\membersection{wxImage::SaveFile}\label{wximagesavefile}
-\func{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
+\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}}
-\func{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
+\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}}
-Saves a image in the named file.
+Saves an image in the named file.
-\func{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
+\constfunc{bool}{SaveFile}{\param{const wxString\& }{name}}
-\func{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
+Saves an image in the named file. File type is determined from the extension of the
+file name. Note that this function may fail if the extension is not recognized! You
+can use one of the forms above to save images to files with non-standard extensions.
-Saves a image in the given stream.
+\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}}
+
+\constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}}
+
+Saves an image in the given stream.
\wxheading{Parameters}
\docparam{stream}{Opened output stream to save the image to.}
-\docparam{type}{Currently three types can be used:
+\docparam{type}{Currently these types can be used:
\twocolwidtha{5cm}%
\begin{twocollist}
+\twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).}
\twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).}
\twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.}
\twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.}
-\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Save a ICO image file. }
\twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Save a Windows icon file (ICO) (the size may be up to 255 wide by 127 high. A single image is saved in 8 colors at the size supplied).}
\twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).}
\end{twocollist}}
hotspot before saving an image into a cursor file (default hotspot is in
the centre of the image):
\begin{verbatim}
- image.SetOption(wxCUR_HOTSPOT_X, hotspotX);
- image.SetOption(wxCUR_HOTSPOT_Y, hotspotY);
+ image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX);
+ image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY);
\end{verbatim}
the size (width*height*3) or results will be unexpected. Don't use this
method if you aren't sure you know what you are doing.
+The data must have been allocated with malloc(), NOT with operator new.
+
+After this call the pointer to the data is owned by the wxImage object,
+that will be responsible for deleting it.
+Do not pass to this function a pointer obtained through
+\helpref{wxImage::GetData}{wximagegetdata}.
+
\membersection{wxImage::SetMask}\label{wximagesetmask}
\func{void}{SetMask}{\param{bool}{ hasMask = TRUE}}
\membersection{wxImage::operator $==$}
-\func{bool}{operator $==$}{\param{const wxImage\& }{image}}
+\constfunc{bool}{operator $==$}{\param{const wxImage\& }{image}}
Equality operator. This operator tests whether the internal data pointers are
equal (a fast test).
\membersection{wxImage::operator $!=$}
-\func{bool}{operator $!=$}{\param{const wxImage\& }{image}}
+\constfunc{bool}{operator $!=$}{\param{const wxImage\& }{image}}
Inequality operator. This operator tests whether the internal data pointers are
unequal (a fast test).