]>
Commit | Line | Data |
---|---|---|
1e6d9499 JS |
1 | \section{\class{wxImage}}\label{wximage} |
2 | ||
3 | This class encapsulates a platform-independent image. An image can be created | |
b06a6b20 | 4 | from data, or using \helpref{wxBitmap::ConvertToImage}{wxbitmapconverttoimage}. An image |
1e6d9499 JS |
5 | can be loaded from a file in a variety of formats, and is extensible to new formats |
6 | via image format handlers. Functions are available to set and get image bits, so | |
7 | it can be used for basic image manipulation. | |
8 | ||
7468b994 RR |
9 | A wxImage cannot (currently) be drawn directly to a \helpref{wxDC}{wxdc}. Instead, |
10 | a platform-specific \helpref{wxBitmap}{wxbitmap} object must be created from it using | |
b06a6b20 VS |
11 | the \helpref{wxBitmap::wxBitmap(wxImage,int depth)}{wxbitmapconstr} constructor. |
12 | This bitmap can then | |
7468b994 RR |
13 | be drawn in a device context, using \helpref{wxDC::DrawBitmap}{wxdcdrawbitmap}. |
14 | ||
15 | One colour value of the image may be used as a mask colour which will lead to the automatic | |
16 | creation of a \helpref{wxMask}{wxmask} object associated to the bitmap object. | |
12a44087 | 17 | |
487659e0 VZ |
18 | \wxheading{Alpha channel support} |
19 | ||
20 | Starting from wxWindows 2.5.0 wxImage supports alpha channel data, that is in | |
21 | addition to a byte for the red, green and blue colour components for each pixel | |
22 | it also stores a byte representing the pixel opacity. The alpha value of $0$ | |
23 | corresponds to a transparent pixel (null opacity) while the value of $255$ | |
24 | means that the pixel is 100\% opaque. | |
25 | ||
26 | Unlike the RGB data, not all images have the alpha channel and before using | |
27 | \helpref{GetAlpha}{wximagegetalpha} you should check if this image contains | |
28 | alpha value with \helpref{HasAlpha}{wximagehasalpha}. In fact, currently only | |
29 | images loaded from PNG files with transparency information will have alpha | |
30 | channel but support for it will be added to the other formats as well (as well | |
31 | as support for saving images with alpha channel which is not still implemented | |
939fadc8 | 32 | either). |
487659e0 | 33 | |
8727a1fe GRG |
34 | \wxheading{Available image handlers} |
35 | ||
36 | The following image handlers are available. {\bf wxBMPHandler} is always | |
2edb0bde | 37 | installed by default. To use other image formats, install the appropriate |
fa482912 | 38 | handler with \helpref{wxImage::AddHandler}{wximageaddhandler} or |
8727a1fe GRG |
39 | \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}. |
40 | ||
41 | \twocolwidtha{5cm}% | |
42 | \begin{twocollist} | |
4fa0a5b4 | 43 | \twocolitem{\indexit{wxBMPHandler}}{For loading and saving, always installed.} |
487659e0 | 44 | \twocolitem{\indexit{wxPNGHandler}}{For loading (including alpha support) and saving.} |
606a3178 GT |
45 | \twocolitem{\indexit{wxJPEGHandler}}{For loading and saving.} |
46 | \twocolitem{\indexit{wxGIFHandler}}{Only for loading, due to legal issues.} | |
47 | \twocolitem{\indexit{wxPCXHandler}}{For loading and saving (see below).} | |
48 | \twocolitem{\indexit{wxPNMHandler}}{For loading and saving (see below).} | |
b86e511a | 49 | \twocolitem{\indexit{wxTIFFHandler}}{For loading and saving.} |
4fa0a5b4 | 50 | \twocolitem{\indexit{wxIFFHandler}}{For loading only.} |
b86e511a | 51 | \twocolitem{\indexit{wxXPMHandler}}{For loading and saving.} |
37b83ca6 | 52 | \twocolitem{\indexit{wxICOHandler}}{For loading and saving.} |
a61d25e6 | 53 | \twocolitem{\indexit{wxCURHandler}}{For loading and saving.} |
4fa0a5b4 | 54 | \twocolitem{\indexit{wxANIHandler}}{For loading only.} |
8727a1fe GRG |
55 | \end{twocollist} |
56 | ||
57 | When saving in PCX format, {\bf wxPCXHandler} will count the number of | |
58 | different colours in the image; if there are 256 or less colours, it will | |
59 | save as 8 bit, else it will save as 24 bit. | |
60 | ||
61 | Loading PNMs only works for ASCII or raw RGB images. When saving in | |
62 | PNM format, {\bf wxPNMHandler} will always save as raw RGB. | |
63 | ||
1e6d9499 JS |
64 | \wxheading{Derived from} |
65 | ||
66 | \helpref{wxObject}{wxobject} | |
67 | ||
954b8ae6 JS |
68 | \wxheading{Include files} |
69 | ||
70 | <wx/image.h> | |
71 | ||
1e6d9499 JS |
72 | \wxheading{See also} |
73 | ||
f6081a04 | 74 | \helpref{wxBitmap}{wxbitmap}, |
b5a4a47d | 75 | \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers} |
1e6d9499 JS |
76 | |
77 | \latexignore{\rtfignore{\wxheading{Members}}} | |
78 | ||
79 | \membersection{wxImage::wxImage}\label{wximageconstr} | |
80 | ||
81 | \func{}{wxImage}{\void} | |
82 | ||
83 | Default constructor. | |
84 | ||
85 | \func{}{wxImage}{\param{const wxImage\& }{image}} | |
86 | ||
87 | Copy constructor. | |
88 | ||
89 | \func{}{wxImage}{\param{const wxBitmap\&}{ bitmap}} | |
90 | ||
b06a6b20 VS |
91 | (Deprecated form, use \helpref{wxBitmap::ConvertToImage}{wxbitmapconverttoimage} |
92 | instead.) Constructs an image from a platform-dependent bitmap. This preserves | |
12a44087 RR |
93 | mask information so that bitmaps and images can be converted back |
94 | and forth without loss in that respect. | |
1e6d9499 | 95 | |
ff865c13 | 96 | \func{}{wxImage}{\param{int}{ width}, \param{int}{ height}, \param{bool}{ clear=true}} |
1e6d9499 | 97 | |
ff865c13 JS |
98 | Creates an image with the given width and height. If {\it clear} is true, the new image will be initialized to black. |
99 | Otherwise, the image data will be uninitialized. | |
1e6d9499 | 100 | |
cc81d32f | 101 | \func{}{wxImage}{\param{int}{ width}, \param{int}{ height}, \param{unsigned char*}{ data}, \param{bool}{ static\_data=false}} |
f6bcfd97 BP |
102 | |
103 | Creates an image from given data with the given width and height. If | |
cc81d32f | 104 | {\it static\_data} is true, then wxImage will not delete the actual |
f6bcfd97 BP |
105 | image data in its destructor, otherwise it will free it by calling |
106 | {\it free()}. | |
107 | ||
a61d25e6 | 108 | \func{}{wxImage}{\param{const wxString\& }{name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}} |
1e6d9499 | 109 | |
a61d25e6 | 110 | \func{}{wxImage}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}} |
9e9ee68e | 111 | |
1e6d9499 JS |
112 | Loads an image from a file. |
113 | ||
a61d25e6 | 114 | \func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}} |
45b5751f | 115 | |
a61d25e6 | 116 | \func{}{wxImage}{\param{wxInputStream\& }{stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}} |
9e9ee68e | 117 | |
45b5751f JS |
118 | Loads an image from an input stream. |
119 | ||
1e6d9499 JS |
120 | \wxheading{Parameters} |
121 | ||
122 | \docparam{width}{Specifies the width of the image.} | |
123 | ||
124 | \docparam{height}{Specifies the height of the image.} | |
125 | ||
31fd9b6b | 126 | \docparam{name}{Name of the file from which to load the image.} |
1e6d9499 | 127 | |
31fd9b6b | 128 | \docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.} |
45b5751f | 129 | |
1e6d9499 JS |
130 | \docparam{type}{May be one of the following: |
131 | ||
6be663cf | 132 | \twocolwidtha{5cm}% |
1e6d9499 | 133 | \begin{twocollist} |
606a3178 GT |
134 | \twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.} |
135 | \twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.} | |
136 | \twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.} | |
137 | \twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.} | |
138 | \twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.} | |
139 | \twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.} | |
140 | \twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.} | |
b86e511a | 141 | \twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.} |
a61d25e6 VS |
142 | \twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).} |
143 | \twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).} | |
658974ae | 144 | \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).} |
606a3178 | 145 | \twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.} |
31fd9b6b | 146 | \end{twocollist}} |
1e6d9499 | 147 | |
9e9ee68e VS |
148 | \docparam{mimetype}{MIME type string (for example 'image/jpeg')} |
149 | ||
a61d25e6 | 150 | \docparam{index}{Index of the image to load in the case that the image file contains multiple images. |
b931f7ee | 151 | This is only used by GIF, ICO and TIFF handlers. The default value (-1) means |
a61d25e6 | 152 | "choose the default image" and is interpreted as the first image (index=0) by |
b931f7ee | 153 | the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.} |
a61d25e6 | 154 | |
31fd9b6b GRG |
155 | \wxheading{Remarks} |
156 | ||
157 | Depending on how wxWindows has been configured, not all formats may be available. | |
158 | ||
fa482912 JS |
159 | Note: any handler other than BMP must be previously |
160 | initialized with \helpref{wxImage::AddHandler}{wximageaddhandler} or | |
31fd9b6b | 161 | \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers}. |
0a9f2522 | 162 | |
a61d25e6 VS |
163 | Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the |
164 | hotspot for loaded cursor file: | |
165 | \begin{verbatim} | |
fd94e8aa VS |
166 | int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X); |
167 | int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y); | |
a61d25e6 VS |
168 | |
169 | \end{verbatim} | |
170 | ||
1e6d9499 JS |
171 | \wxheading{See also} |
172 | ||
173 | \helpref{wxImage::LoadFile}{wximageloadfile} | |
174 | ||
f899db6d RD |
175 | \pythonnote{Constructors supported by wxPython are:\par |
176 | \indented{2cm}{\begin{twocollist} | |
c9110876 VS |
177 | \twocolitem{{\bf wxImage(name, flag)}}{Loads an image from a file} |
178 | \twocolitem{{\bf wxNullImage()}}{Create a null image (has no size or | |
f899db6d | 179 | image data)} |
c9110876 | 180 | \twocolitem{{\bf wxEmptyImage(width, height)}}{Creates an empty image |
f899db6d | 181 | of the given size} |
c9110876 | 182 | \twocolitem{{\bf wxImageFromMime(name, mimetype}}{Creates an image from |
f899db6d | 183 | the given file of the given mimetype} |
c9110876 | 184 | \twocolitem{{\bf wxImageFromBitmap(bitmap)}}{Creates an image from a |
f899db6d RD |
185 | platform-dependent bitmap} |
186 | \end{twocollist}} | |
187 | } | |
188 | ||
5873607e VZ |
189 | \perlnote{Constructors supported by wxPerl are:\par |
190 | \begin{itemize} | |
191 | \item{Wx::Image->new( bitmap )} | |
192 | \item{Wx::Image->new( width, height )} | |
193 | \item{Wx::Image->new( name, type )} | |
194 | \item{Wx::Image->new( name, mimetype )} | |
195 | \end{itemize} | |
196 | } | |
197 | ||
1e6d9499 JS |
198 | \membersection{wxImage::\destruct{wxImage}} |
199 | ||
200 | \func{}{\destruct{wxImage}}{\void} | |
201 | ||
202 | Destructor. | |
203 | ||
204 | \membersection{wxImage::AddHandler}\label{wximageaddhandler} | |
205 | ||
206 | \func{static void}{AddHandler}{\param{wxImageHandler*}{ handler}} | |
207 | ||
208 | Adds a handler to the end of the static list of format handlers. | |
209 | ||
210 | \docparam{handler}{A new image format handler object. There is usually only one instance | |
211 | of a given handler class in an application session.} | |
212 | ||
213 | \wxheading{See also} | |
214 | ||
215 | \helpref{wxImageHandler}{wximagehandler} | |
216 | ||
4fa0a5b4 VS |
217 | \func{bool}{CanRead}{\param{const wxString\&}{ filename}} |
218 | ||
cc81d32f | 219 | returns true if the current image handlers can read this file |
4fa0a5b4 | 220 | |
e7240349 | 221 | \pythonnote{In wxPython this static method is named {\tt wxImage\_AddHandler}.} |
1e6d9499 JS |
222 | \membersection{wxImage::CleanUpHandlers} |
223 | ||
224 | \func{static void}{CleanUpHandlers}{\void} | |
225 | ||
226 | Deletes all image handlers. | |
227 | ||
228 | This function is called by wxWindows on exit. | |
229 | ||
d7af2fea VS |
230 | \membersection{wxImage::ComputeHistogram}\label{wximagecomputehistogram} |
231 | ||
232 | \constfunc{unsigned long}{ComputeHistogram}{\param{wxImageHistogram\& }{histogram}} | |
233 | ||
234 | Computes the histogram of the image. {\it histogram} is a reference to | |
235 | wxImageHistogram object. wxImageHistogram is a specialization of | |
236 | \helpref{wxHashMap}{wxhashmap} "template" and is defined as follows: | |
237 | ||
238 | \begin{verbatim} | |
239 | class WXDLLEXPORT wxImageHistogramEntry | |
240 | { | |
241 | public: | |
242 | wxImageHistogramEntry() : index(0), value(0) {} | |
243 | unsigned long index; | |
244 | unsigned long value; | |
245 | }; | |
246 | ||
247 | WX_DECLARE_EXPORTED_HASH_MAP(unsigned long, wxImageHistogramEntry, | |
248 | wxIntegerHash, wxIntegerEqual, | |
249 | wxImageHistogram); | |
250 | \end{verbatim} | |
251 | ||
252 | \wxheading{Return value} | |
253 | ||
254 | Returns number of colours in the histogram. | |
255 | ||
1e6d9499 JS |
256 | \membersection{wxImage::ConvertToBitmap}\label{wximageconverttobitmap} |
257 | ||
258 | \constfunc{wxBitmap}{ConvertToBitmap}{\void} | |
259 | ||
b06a6b20 VS |
260 | Deprecated, use equivalent \helpref{wxBitmap constructor}{wxbitmapconstr} |
261 | (which takes wxImage and depth as its arguments) instead. | |
7468b994 | 262 | |
b06a6b20 | 263 | \membersection{wxImage::ConvertToMono}\label{wxbitmapconverttomono} |
1e6d9499 | 264 | |
b06a6b20 VS |
265 | \constfunc{wxImage}{ConvertToMono}{\param{unsigned char}{ r}, \param{unsigned char}{ g}, \param{unsigned char}{ b}} |
266 | ||
267 | Returns monochromatic version of the image. The returned image has white | |
268 | colour where the original has {\it (r,g,b)} colour and black colour | |
269 | everywhere else. | |
3ca6a5f0 | 270 | |
f6bcfd97 BP |
271 | \membersection{wxImage::Copy}\label{wximagecopy} |
272 | ||
273 | \constfunc{wxImage}{Copy}{\void} | |
274 | ||
275 | Returns an identical copy of the image. | |
276 | ||
1e6d9499 JS |
277 | \membersection{wxImage::Create}\label{wximagecreate} |
278 | ||
ff865c13 | 279 | \func{bool}{Create}{\param{int}{ width}, \param{int}{ height}, \param{bool}{ clear=true}} |
1e6d9499 | 280 | |
ff865c13 JS |
281 | Creates a fresh image. If {\it clear} is true, the new image will be initialized to black. |
282 | Otherwise, the image data will be uninitialized. | |
1e6d9499 JS |
283 | |
284 | \wxheading{Parameters} | |
285 | ||
286 | \docparam{width}{The width of the image in pixels.} | |
287 | ||
288 | \docparam{height}{The height of the image in pixels.} | |
289 | ||
290 | \wxheading{Return value} | |
291 | ||
cc81d32f | 292 | true if the call succeeded, false otherwise. |
1e6d9499 JS |
293 | |
294 | \membersection{wxImage::Destroy}\label{wximagedestroy} | |
295 | ||
296 | \func{bool}{Destroy}{\void} | |
297 | ||
298 | Destroys the image data. | |
299 | ||
37b83ca6 VS |
300 | \membersection{wxImage::FindFirstUnusedColour}\label{wximagefindfirstunusedcolour} |
301 | ||
302 | \func{bool}{FindFirstUnusedColour}{\param{unsigned char *}{ r}, \param{unsigned char *}{ g}, \param{unsigned char *}{ b}, \param{unsigned char}{ startR = 1}, \param{unsigned char}{ startG = 0}, \param{unsigned char}{ startB = 0}} | |
303 | ||
304 | \wxheading{Parameters} | |
305 | ||
306 | \docparam{r,g,b}{Pointers to variables to save the colour.} | |
307 | ||
308 | \docparam{startR,startG,startB}{Initial values of the colour. Returned colour | |
309 | will have RGB values equal to or greater than these.} | |
310 | ||
311 | Finds the first colour that is never used in the image. The search begins at | |
312 | given initial colour and continues by increasing R, G and B components (in this | |
313 | order) by 1 until an unused colour is found or the colour space exhausted. | |
314 | ||
315 | \wxheading{Return value} | |
316 | ||
cc81d32f | 317 | Returns false if there is no unused colour left, true on success. |
37b83ca6 VS |
318 | |
319 | \wxheading{Notes} | |
320 | ||
321 | Note that this method involves computing the histogram, which is | |
322 | computationally intensive operation. | |
323 | ||
1e6d9499 JS |
324 | \membersection{wxImage::FindHandler} |
325 | ||
326 | \func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{name}} | |
327 | ||
328 | Finds the handler with the given name. | |
329 | ||
330 | \func{static wxImageHandler*}{FindHandler}{\param{const wxString\& }{extension}, \param{long}{ imageType}} | |
331 | ||
332 | Finds the handler associated with the given extension and type. | |
333 | ||
334 | \func{static wxImageHandler*}{FindHandler}{\param{long }{imageType}} | |
335 | ||
336 | Finds the handler associated with the given image type. | |
337 | ||
9e9ee68e VS |
338 | \func{static wxImageHandler*}{FindHandlerMime}{\param{const wxString\& }{mimetype}} |
339 | ||
340 | Finds the handler associated with the given MIME type. | |
341 | ||
1e6d9499 JS |
342 | \docparam{name}{The handler name.} |
343 | ||
344 | \docparam{extension}{The file extension, such as ``bmp".} | |
345 | ||
f6fcbb63 | 346 | \docparam{imageType}{The image type, such as wxBITMAP\_TYPE\_BMP.} |
1e6d9499 | 347 | |
9e9ee68e VS |
348 | \docparam{mimetype}{MIME type.} |
349 | ||
1e6d9499 JS |
350 | \wxheading{Return value} |
351 | ||
352 | A pointer to the handler if found, NULL otherwise. | |
353 | ||
354 | \wxheading{See also} | |
355 | ||
356 | \helpref{wxImageHandler}{wximagehandler} | |
357 | ||
939fadc8 JS |
358 | \membersection{wxImage::GetImageExtWildcard} |
359 | ||
360 | \func{static wxString}{GetImageExtWildcard}{\void} | |
361 | ||
362 | Iterates all registered wxImageHandler objects, and returns a string containing file extension masks | |
363 | suitable for passing to file open/save dialog boxes. | |
364 | ||
365 | \wxheading{Return value} | |
366 | ||
367 | The format of the returned string is "(*.ext1;*.ext2)|*.ext1;*.ext2". | |
368 | ||
369 | It is usually a good idea to prepend a description before passing the result to the dialog. | |
370 | ||
371 | Example: | |
372 | ||
373 | \begin{verbatim} | |
374 | wxFileDialog FileDlg( this, "Choose Image", ::wxGetWorkingDirectory(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxOPEN ); | |
375 | \end{verbatim} | |
376 | ||
377 | \wxheading{See also} | |
378 | ||
379 | \helpref{wxImageHandler}{wximagehandler} | |
380 | ||
487659e0 VZ |
381 | \membersection{wxImage::GetAlpha}\label{wximagegetalpha} |
382 | ||
383 | \constfunc{unsigned char}{GetAlpha}{\param{int}{ x}, \param{int}{ y}} | |
384 | ||
385 | Returns the alpha value for the given pixel. This function may only be called | |
386 | for the images with alpha channel, use \helpref{HasAlpha}{wximagehasalpha} to | |
387 | check for this. | |
388 | ||
389 | The returned value is the {\it opacity} of the image, i.e. the value of $0$ | |
390 | corresponds to the transparent pixels while the value of $255$ -- to the opaque | |
391 | ones. | |
392 | ||
393 | \constfunc{unsigned char *}{GetAlpha}{\void} | |
394 | ||
395 | Returns pointer to the array storing the alpha values for this image. This | |
396 | pointer is {\tt NULL} for the images without the alpha channel. If the image | |
397 | does have it, this pointer may be used to directly manipulate the alpha values | |
398 | which are stored as the \helpref{RGB}{wximagegetdata} ones. | |
399 | ||
1e6d9499 JS |
400 | \membersection{wxImage::GetBlue}\label{wximagegetblue} |
401 | ||
402 | \constfunc{unsigned char}{GetBlue}{\param{int}{ x}, \param{int}{ y}} | |
403 | ||
404 | Returns the blue intensity at the given coordinate. | |
405 | ||
406 | \membersection{wxImage::GetData}\label{wximagegetdata} | |
407 | ||
408 | \constfunc{unsigned char*}{GetData}{\void} | |
409 | ||
12a44087 RR |
410 | Returns the image data as an array. This is most often used when doing |
411 | direct image manipulation. The return value points to an array of | |
487659e0 VZ |
412 | characters in RGBRGBRGB$\ldots$ format in the top-to-bottom, left-to-right |
413 | order, that is the first RGB triplet corresponds to the pixel $(0, 0)$, the | |
414 | second one --- to $(0, 1)$ and so on. | |
1e6d9499 | 415 | |
f811bc9a MB |
416 | You should not delete the returned pointer nor pass it to |
417 | \helpref{wxImage::SetData}{wximagesetdata}. | |
418 | ||
1e6d9499 JS |
419 | \membersection{wxImage::GetGreen}\label{wximagegetgreen} |
420 | ||
421 | \constfunc{unsigned char}{GetGreen}{\param{int}{ x}, \param{int}{ y}} | |
422 | ||
423 | Returns the green intensity at the given coordinate. | |
424 | ||
649d13e8 | 425 | \membersection{wxImage::GetImageCount}\label{wximagegetimagecount} |
a61d25e6 | 426 | |
649d13e8 | 427 | \func{static int}{GetImageCount}{\param{const wxString\&}{ filename}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}} |
a61d25e6 | 428 | |
649d13e8 | 429 | \func{static int}{GetImageCount}{\param{wxInputStream\&}{ stream}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}} |
a61d25e6 VS |
430 | |
431 | If the image file contains more than one image and the image handler is capable | |
432 | of retrieving these individually, this function will return the number of | |
433 | available images. | |
434 | ||
435 | \docparam{name}{Name of the file to query.} | |
436 | ||
437 | \docparam{stream}{Opened input stream with image data. Currently, the stream must support seeking.} | |
438 | ||
439 | \docparam{type}{May be one of the following: | |
440 | ||
441 | \twocolwidtha{5cm}% | |
442 | \begin{twocollist} | |
443 | \twocolitem{\indexit{wxBITMAP\_TYPE\_BMP}}{Load a Windows bitmap file.} | |
444 | \twocolitem{\indexit{wxBITMAP\_TYPE\_GIF}}{Load a GIF bitmap file.} | |
445 | \twocolitem{\indexit{wxBITMAP\_TYPE\_JPEG}}{Load a JPEG bitmap file.} | |
446 | \twocolitem{\indexit{wxBITMAP\_TYPE\_PNG}}{Load a PNG bitmap file.} | |
447 | \twocolitem{\indexit{wxBITMAP\_TYPE\_PCX}}{Load a PCX bitmap file.} | |
448 | \twocolitem{\indexit{wxBITMAP\_TYPE\_PNM}}{Load a PNM bitmap file.} | |
449 | \twocolitem{\indexit{wxBITMAP\_TYPE\_TIF}}{Load a TIFF bitmap file.} | |
450 | \twocolitem{\indexit{wxBITMAP\_TYPE\_XPM}}{Load a XPM bitmap file.} | |
451 | \twocolitem{\indexit{wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).} | |
452 | \twocolitem{\indexit{wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).} | |
658974ae | 453 | \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).} |
a61d25e6 VS |
454 | \twocolitem{\indexit{wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.} |
455 | \end{twocollist}} | |
456 | ||
457 | \wxheading{Return value} | |
458 | ||
459 | Number of available images. For most image handlers, this is 1 (exceptions | |
460 | are TIFF and ICO formats). | |
461 | ||
1e6d9499 JS |
462 | \membersection{wxImage::GetHandlers} |
463 | ||
464 | \func{static wxList\&}{GetHandlers}{\void} | |
465 | ||
466 | Returns the static list of image format handlers. | |
467 | ||
468 | \wxheading{See also} | |
469 | ||
470 | \helpref{wxImageHandler}{wximagehandler} | |
471 | ||
472 | \membersection{wxImage::GetHeight}\label{wximagegetheight} | |
473 | ||
474 | \constfunc{int}{GetHeight}{\void} | |
475 | ||
476 | Gets the height of the image in pixels. | |
477 | ||
478 | \membersection{wxImage::GetMaskBlue}\label{wximagegetmaskblue} | |
479 | ||
480 | \constfunc{unsigned char}{GetMaskBlue}{\void} | |
481 | ||
482 | Gets the blue value of the mask colour. | |
483 | ||
484 | \membersection{wxImage::GetMaskGreen}\label{wximagegetmaskgreen} | |
485 | ||
486 | \constfunc{unsigned char}{GetMaskGreen}{\void} | |
487 | ||
488 | Gets the green value of the mask colour. | |
489 | ||
490 | \membersection{wxImage::GetMaskRed}\label{wximagegetmaskred} | |
491 | ||
492 | \constfunc{unsigned char}{GetMaskRed}{\void} | |
493 | ||
494 | Gets the red value of the mask colour. | |
495 | ||
3ca6a5f0 BP |
496 | \membersection{wxImage::GetPalette}\label{wximagegetpalette} |
497 | ||
498 | \constfunc{const wxPalette\&}{GetPalette}{\void} | |
499 | ||
500 | Returns the palette associated with the image. Currently the palette is only | |
b06a6b20 | 501 | used when converting to wxBitmap under Windows. |
3ca6a5f0 BP |
502 | |
503 | Eventually wxImage handlers will set the palette if one exists in the image file. | |
504 | ||
7b4c3149 VZ |
505 | \membersection{wxImage::GetRed}\label{wximagegetred} |
506 | ||
507 | \constfunc{unsigned char}{GetRed}{\param{int}{ x}, \param{int}{ y}} | |
508 | ||
509 | Returns the red intensity at the given coordinate. | |
510 | ||
fc9c7c09 RR |
511 | \membersection{wxImage::GetSubImage}\label{wximagegetsubimage} |
512 | ||
7468b994 | 513 | \constfunc{wxImage}{GetSubImage}{\param{const wxRect\&}{ rect}} |
fc9c7c09 RR |
514 | |
515 | Returns a sub image of the current one as long as the rect belongs entirely to | |
516 | the image. | |
517 | ||
1e6d9499 JS |
518 | \membersection{wxImage::GetWidth}\label{wximagegetwidth} |
519 | ||
520 | \constfunc{int}{GetWidth}{\void} | |
521 | ||
522 | Gets the width of the image in pixels. | |
523 | ||
524 | \wxheading{See also} | |
525 | ||
526 | \helpref{wxImage::GetHeight}{wximagegetheight} | |
527 | ||
487659e0 VZ |
528 | \membersection{wxImage::HasAlpha}\label{wximagehasalpha} |
529 | ||
530 | \constfunc{bool}{HasAlpha}{\void} | |
531 | ||
532 | Returns true if this image has alpha channel, false otherwise. | |
533 | ||
534 | \wxheading{See also} | |
535 | ||
536 | \helpref{GetAlpha}{wximagegetalpha}, \helpref{SetAlpha}{wximagesetalpha} | |
537 | ||
1e6d9499 JS |
538 | \membersection{wxImage::HasMask}\label{wximagehasmask} |
539 | ||
540 | \constfunc{bool}{HasMask}{\void} | |
541 | ||
cc81d32f | 542 | Returns true if there is a mask active, false otherwise. |
1e6d9499 | 543 | |
5e5437e0 JS |
544 | \membersection{wxImage::GetOption}\label{wximagegetoption} |
545 | ||
546 | \constfunc{wxString}{GetOption}{\param{const wxString\&}{ name}} | |
547 | ||
548 | Gets a user-defined option. The function is case-insensitive to {\it name}. | |
549 | ||
550 | For example, when saving as a JPEG file, the option {\bf quality} is | |
551 | used, which is a number between 0 and 100 (0 is terrible, 100 is very good). | |
552 | ||
553 | \wxheading{See also} | |
554 | ||
555 | \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp | |
556 | \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp | |
557 | \helpref{wxImage::HasOption}{wximagehasoption} | |
558 | ||
559 | \membersection{wxImage::GetOptionInt}\label{wximagegetoptionint} | |
560 | ||
561 | \constfunc{int}{GetOptionInt}{\param{const wxString\&}{ name}} | |
562 | ||
563 | Gets a user-defined option as an integer. The function is case-insensitive to {\it name}. | |
564 | ||
565 | \wxheading{See also} | |
566 | ||
567 | \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp | |
568 | \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp | |
569 | \helpref{wxImage::HasOption}{wximagehasoption} | |
570 | ||
571 | \membersection{wxImage::HasOption}\label{wximagehasoption} | |
572 | ||
573 | \constfunc{bool}{HasOption}{\param{const wxString\&}{ name}} | |
574 | ||
cc81d32f | 575 | Returns true if the given option is present. The function is case-insensitive to {\it name}. |
5e5437e0 JS |
576 | |
577 | \wxheading{See also} | |
578 | ||
579 | \helpref{wxImage::SetOption}{wximagesetoption},\rtfsp | |
580 | \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp | |
581 | \helpref{wxImage::GetOptionInt}{wximagegetoptionint} | |
582 | ||
1e6d9499 JS |
583 | \membersection{wxImage::InitStandardHandlers} |
584 | ||
585 | \func{static void}{InitStandardHandlers}{\void} | |
586 | ||
a14e57f9 | 587 | Internal use only. Adds standard image format handlers. It only install BMP |
31fd9b6b | 588 | for the time being, which is used by wxBitmap. |
1e6d9499 | 589 | |
a14e57f9 SB |
590 | This function is called by wxWindows on startup, and shouldn't be called by |
591 | the user. | |
1e6d9499 JS |
592 | |
593 | \wxheading{See also} | |
594 | ||
fa482912 | 595 | \helpref{wxImageHandler}{wximagehandler}, |
b5a4a47d | 596 | \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers} |
1e6d9499 JS |
597 | |
598 | \membersection{wxImage::InsertHandler} | |
599 | ||
600 | \func{static void}{InsertHandler}{\param{wxImageHandler*}{ handler}} | |
601 | ||
602 | Adds a handler at the start of the static list of format handlers. | |
603 | ||
604 | \docparam{handler}{A new image format handler object. There is usually only one instance | |
605 | of a given handler class in an application session.} | |
606 | ||
607 | \wxheading{See also} | |
608 | ||
609 | \helpref{wxImageHandler}{wximagehandler} | |
610 | ||
611 | \membersection{wxImage::LoadFile}\label{wximageloadfile} | |
612 | ||
a61d25e6 | 613 | \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{long}{ type = wxBITMAP\_TYPE\_ANY}, \param{int}{ index = -1}} |
1e6d9499 | 614 | |
a61d25e6 | 615 | \func{bool}{LoadFile}{\param{const wxString\&}{ name}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}} |
9e9ee68e | 616 | |
a14e57f9 | 617 | Loads an image from a file. If no handler type is provided, the library will |
31fd9b6b | 618 | try to autodetect the format. |
1e6d9499 | 619 | |
a61d25e6 | 620 | \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{long}{ type}, \param{int}{ index = -1}} |
45b5751f | 621 | |
a61d25e6 | 622 | \func{bool}{LoadFile}{\param{wxInputStream\&}{ stream}, \param{const wxString\&}{ mimetype}, \param{int}{ index = -1}} |
9e9ee68e | 623 | |
45b5751f JS |
624 | Loads an image from an input stream. |
625 | ||
1e6d9499 JS |
626 | \wxheading{Parameters} |
627 | ||
31fd9b6b | 628 | \docparam{name}{Name of the file from which to load the image.} |
1e6d9499 | 629 | |
31fd9b6b | 630 | \docparam{stream}{Opened input stream from which to load the image. Currently, the stream must support seeking.} |
45b5751f | 631 | |
1e6d9499 JS |
632 | \docparam{type}{One of the following values: |
633 | ||
6be663cf | 634 | \twocolwidtha{5cm}% |
1e6d9499 | 635 | \begin{twocollist} |
f6fcbb63 | 636 | \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Load a Windows image file.} |
a14e57f9 | 637 | \twocolitem{{\bf wxBITMAP\_TYPE\_GIF}}{Load a GIF image file.} |
48b4e302 | 638 | \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Load a JPEG image file.} |
a14e57f9 SB |
639 | \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Load a PCX image file.} |
640 | \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Load a PNG image file.} | |
641 | \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Load a PNM image file.} | |
31fd9b6b | 642 | \twocolitem{{\bf wxBITMAP\_TYPE\_TIF}}{Load a TIFF image file.} |
b86e511a | 643 | \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Load a XPM image file.} |
a61d25e6 VS |
644 | \twocolitem{{\bf wxBITMAP\_TYPE\_ICO}}{Load a Windows icon file (ICO).} |
645 | \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Load a Windows cursor file (CUR).} | |
658974ae | 646 | \twocolitem{\indexit{wxBITMAP\_TYPE\_ANI}}{Load a Windows animated cursor file (ANI).} |
31fd9b6b GRG |
647 | \twocolitem{{\bf wxBITMAP\_TYPE\_ANY}}{Will try to autodetect the format.} |
648 | \end{twocollist}} | |
1e6d9499 | 649 | |
9e9ee68e VS |
650 | \docparam{mimetype}{MIME type string (for example 'image/jpeg')} |
651 | ||
a61d25e6 | 652 | \docparam{index}{Index of the image to load in the case that the image file contains multiple images. |
b931f7ee | 653 | This is only used by GIF, ICO and TIFF handlers. The default value (-1) means |
a61d25e6 | 654 | "choose the default image" and is interpreted as the first image (index=0) by |
b931f7ee | 655 | the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.} |
a61d25e6 | 656 | |
31fd9b6b GRG |
657 | \wxheading{Remarks} |
658 | ||
659 | Depending on how wxWindows has been configured, not all formats may be available. | |
660 | ||
a61d25e6 VS |
661 | Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to get the |
662 | hotspot for loaded cursor file: | |
663 | \begin{verbatim} | |
fd94e8aa VS |
664 | int hotspot_x = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X); |
665 | int hotspot_y = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y); | |
a61d25e6 VS |
666 | |
667 | \end{verbatim} | |
37b83ca6 | 668 | |
1e6d9499 JS |
669 | \wxheading{Return value} |
670 | ||
cc81d32f VS |
671 | true if the operation succeeded, false otherwise. If the optional index parameter is out of range, |
672 | false is returned and a call to wxLogError() takes place. | |
1e6d9499 JS |
673 | |
674 | \wxheading{See also} | |
675 | ||
676 | \helpref{wxImage::SaveFile}{wximagesavefile} | |
677 | ||
f899db6d RD |
678 | \pythonnote{In place of a single overloaded method name, wxPython |
679 | implements the following methods:\par | |
680 | \indented{2cm}{\begin{twocollist} | |
c9110876 | 681 | \twocolitem{{\bf LoadFile(filename, type)}}{Loads an image of the given |
f899db6d | 682 | type from a file} |
c9110876 | 683 | \twocolitem{{\bf LoadMimeFile(filename, mimetype)}}{Loads an image of the given |
f899db6d RD |
684 | mimetype from a file} |
685 | \end{twocollist}} | |
686 | } | |
687 | ||
5873607e VZ |
688 | \perlnote{Methods supported by wxPerl are:\par |
689 | \begin{itemize} | |
606a3178 GT |
690 | \item{bitmap->LoadFile( name, type )} |
691 | \item{bitmap->LoadFile( name, mimetype )} | |
5873607e VZ |
692 | \end{itemize} |
693 | } | |
694 | ||
f899db6d | 695 | |
1e6d9499 JS |
696 | \membersection{wxImage::Ok}\label{wximageok} |
697 | ||
698 | \constfunc{bool}{Ok}{\void} | |
699 | ||
cc81d32f | 700 | Returns true if image data is present. |
1e6d9499 JS |
701 | |
702 | \membersection{wxImage::RemoveHandler} | |
703 | ||
704 | \func{static bool}{RemoveHandler}{\param{const wxString\& }{name}} | |
705 | ||
706 | Finds the handler with the given name, and removes it. The handler | |
707 | is not deleted. | |
708 | ||
709 | \docparam{name}{The handler name.} | |
710 | ||
711 | \wxheading{Return value} | |
712 | ||
cc81d32f | 713 | true if the handler was found and removed, false otherwise. |
1e6d9499 JS |
714 | |
715 | \wxheading{See also} | |
716 | ||
717 | \helpref{wxImageHandler}{wximagehandler} | |
718 | ||
719 | \membersection{wxImage::SaveFile}\label{wximagesavefile} | |
720 | ||
d7af2fea | 721 | \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{int}{ type}} |
1e6d9499 | 722 | |
d7af2fea | 723 | \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}, \param{const wxString\&}{ mimetype}} |
9e9ee68e | 724 | |
4fa0a5b4 VS |
725 | Saves an image in the named file. |
726 | ||
727 | \constfunc{bool}{SaveFile}{\param{const wxString\& }{name}} | |
728 | ||
729 | Saves an image in the named file. File type is determined from the extension of the | |
730 | file name. Note that this function may fail if the extension is not recognized! You | |
731 | can use one of the forms above to save images to files with non-standard extensions. | |
1e6d9499 | 732 | |
d7af2fea | 733 | \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{int}{ type}} |
45b5751f | 734 | |
d7af2fea | 735 | \constfunc{bool}{SaveFile}{\param{wxOutputStream\& }{stream}, \param{const wxString\&}{ mimetype}} |
9e9ee68e | 736 | |
4fa0a5b4 | 737 | Saves an image in the given stream. |
45b5751f | 738 | |
1e6d9499 JS |
739 | \wxheading{Parameters} |
740 | ||
31fd9b6b | 741 | \docparam{name}{Name of the file to save the image to.} |
1e6d9499 | 742 | |
31fd9b6b | 743 | \docparam{stream}{Opened output stream to save the image to.} |
45b5751f | 744 | |
4fa0a5b4 | 745 | \docparam{type}{Currently these types can be used: |
1e6d9499 | 746 | |
6be663cf | 747 | \twocolwidtha{5cm}% |
1e6d9499 | 748 | \begin{twocollist} |
4fa0a5b4 | 749 | \twocolitem{{\bf wxBITMAP\_TYPE\_BMP}}{Save a BMP image file.} |
48b4e302 | 750 | \twocolitem{{\bf wxBITMAP\_TYPE\_JPEG}}{Save a JPEG image file.} |
31fd9b6b GRG |
751 | \twocolitem{{\bf wxBITMAP\_TYPE\_PNG}}{Save a PNG image file.} |
752 | \twocolitem{{\bf wxBITMAP\_TYPE\_PCX}}{Save a PCX image file (tries to save as 8-bit if possible, falls back to 24-bit otherwise).} | |
753 | \twocolitem{{\bf wxBITMAP\_TYPE\_PNM}}{Save a PNM image file (as raw RGB always).} | |
b86e511a VS |
754 | \twocolitem{{\bf wxBITMAP\_TYPE\_TIFF}}{Save a TIFF image file.} |
755 | \twocolitem{{\bf wxBITMAP\_TYPE\_XPM}}{Save a XPM image file.} | |
a61d25e6 VS |
756 | \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).} |
757 | \twocolitem{{\bf wxBITMAP\_TYPE\_CUR}}{Save a Windows cursor file (CUR).} | |
31fd9b6b | 758 | \end{twocollist}} |
1e6d9499 | 759 | |
9e9ee68e VS |
760 | \docparam{mimetype}{MIME type.} |
761 | ||
1e6d9499 JS |
762 | \wxheading{Return value} |
763 | ||
cc81d32f | 764 | true if the operation succeeded, false otherwise. |
1e6d9499 JS |
765 | |
766 | \wxheading{Remarks} | |
767 | ||
768 | Depending on how wxWindows has been configured, not all formats may be available. | |
769 | ||
a61d25e6 VS |
770 | Note: you can use \helpref{GetOptionInt}{wximagegetoptionint} to set the |
771 | hotspot before saving an image into a cursor file (default hotspot is in | |
772 | the centre of the image): | |
773 | \begin{verbatim} | |
fd94e8aa VS |
774 | image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, hotspotX); |
775 | image.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, hotspotY); | |
a61d25e6 VS |
776 | |
777 | \end{verbatim} | |
778 | ||
1e6d9499 JS |
779 | \wxheading{See also} |
780 | ||
781 | \helpref{wxImage::LoadFile}{wximageloadfile} | |
782 | ||
f899db6d RD |
783 | \pythonnote{In place of a single overloaded method name, wxPython |
784 | implements the following methods:\par | |
785 | \indented{2cm}{\begin{twocollist} | |
c9110876 | 786 | \twocolitem{{\bf SaveFile(filename, type)}}{Saves the image using the given |
f899db6d | 787 | type to the named file} |
c9110876 | 788 | \twocolitem{{\bf SaveMimeFile(filename, mimetype)}}{Saves the image using the given |
f899db6d RD |
789 | mimetype to the named file} |
790 | \end{twocollist}} | |
791 | } | |
792 | ||
5873607e VZ |
793 | \perlnote{Methods supported by wxPerl are:\par |
794 | \begin{itemize} | |
606a3178 GT |
795 | \item{bitmap->SaveFile( name, type )} |
796 | \item{bitmap->SaveFile( name, mimetype )} | |
5873607e VZ |
797 | \end{itemize} |
798 | } | |
799 | ||
f6bcfd97 BP |
800 | \membersection{wxImage::Mirror}\label{wximagemirror} |
801 | ||
cc81d32f | 802 | \constfunc{wxImage}{Mirror}{\param{bool}{ horizontally = true}} |
f6bcfd97 BP |
803 | |
804 | Returns a mirrored copy of the image. The parameter {\it horizontally} | |
805 | indicates the orientation. | |
806 | ||
7468b994 RR |
807 | \membersection{wxImage::Replace}\label{wximagereplace} |
808 | ||
809 | \func{void}{Replace}{\param{unsigned char}{ r1}, \param{unsigned char}{ g1}, \param{unsigned char}{ b1}, | |
810 | \param{unsigned char}{ r2}, \param{unsigned char}{ g2}, \param{unsigned char}{ b2}} | |
811 | ||
812 | Replaces the colour specified by {\it r1,g1,b1} by the colour {\it r2,g2,b2}. | |
813 | ||
ce9a75d2 VZ |
814 | \membersection{wxImage::Rescale}\label{wximagerescale} |
815 | ||
6e807169 | 816 | \func{wxImage \&}{Rescale}{\param{int}{ width}, \param{int}{ height}} |
ce9a75d2 | 817 | |
9c884972 RR |
818 | Changes the size of the image in-place: after a call to this function, the |
819 | image will have the given width and height. | |
ce9a75d2 | 820 | |
6e807169 VZ |
821 | Returns the (modified) image itself. |
822 | ||
ce9a75d2 VZ |
823 | \wxheading{See also} |
824 | ||
825 | \helpref{Scale}{wximagescale} | |
826 | ||
ed8297b9 | 827 | \membersection{wxImage::Rotate}\label{wximagerotate} |
7a632f10 JS |
828 | |
829 | \func{wxImage}{Rotate}{\param{double}{ angle}, \param{const wxPoint\& }{rotationCentre}, | |
cc81d32f | 830 | \param{bool}{ interpolating = true}, \param{wxPoint*}{ offsetAfterRotation = NULL}} |
7a632f10 | 831 | |
cc81d32f | 832 | Rotates the image about the given point, by {\it angle} radians. Passing true |
b4e87ec3 GRG |
833 | to {\it interpolating} results in better image quality, but is slower. If the |
834 | image has a mask, then the mask colour is used for the uncovered pixels in the | |
835 | rotated image background. Else, black (rgb 0, 0, 0) will be used. | |
7a632f10 JS |
836 | |
837 | Returns the rotated image, leaving this image intact. | |
838 | ||
f6bcfd97 BP |
839 | \membersection{wxImage::Rotate90}\label{wximagerotate90} |
840 | ||
cc81d32f | 841 | \constfunc{wxImage}{Rotate90}{\param{bool}{ clockwise = true}} |
f6bcfd97 BP |
842 | |
843 | Returns a copy of the image rotated 90 degrees in the direction | |
844 | indicated by {\it clockwise}. | |
845 | ||
1e6d9499 JS |
846 | \membersection{wxImage::Scale}\label{wximagescale} |
847 | ||
ce9a75d2 | 848 | \constfunc{wxImage}{Scale}{\param{int}{ width}, \param{int}{ height}} |
1e6d9499 | 849 | |
12a44087 RR |
850 | Returns a scaled version of the image. This is also useful for |
851 | scaling bitmaps in general as the only other way to scale bitmaps | |
ce9a75d2 VZ |
852 | is to blit a wxMemoryDC into another wxMemoryDC. |
853 | ||
7468b994 | 854 | It may be mentioned that the GTK port uses this function internally |
f6bcfd97 | 855 | to scale bitmaps when using mapping modes in wxDC. |
ce9a75d2 VZ |
856 | |
857 | Example: | |
858 | ||
859 | \begin{verbatim} | |
860 | // get the bitmap from somewhere | |
861 | wxBitmap bmp = ...; | |
862 | ||
863 | // rescale it to have size of 32*32 | |
864 | if ( bmp.GetWidth() != 32 || bmp.GetHeight() != 32 ) | |
865 | { | |
af494043 | 866 | wxImage image = bmp.ConvertToImage(); |
b06a6b20 | 867 | bmp = wxBitmap(image.Scale(32, 32)); |
ce9a75d2 VZ |
868 | |
869 | // another possibility: | |
870 | image.Rescale(32, 32); | |
871 | bmp = image; | |
872 | } | |
873 | ||
874 | \end{verbatim} | |
875 | ||
876 | \wxheading{See also} | |
877 | ||
878 | \helpref{Rescale}{wximagerescale} | |
1e6d9499 | 879 | |
487659e0 VZ |
880 | \membersection{wxImage::SetAlpha}\label{wximagesetalpha} |
881 | ||
882 | \func{void}{SetAlpha}{\param{unsigned char *}{alpha = {\tt NULL}}} | |
883 | ||
884 | This function is similar to \helpref{SetData}{wximagesetdata} and has similar | |
885 | restrictions. The pointer passed to it may however be {\tt NULL} in which case | |
886 | the function will allocate the alpha array internally -- this is useful to add | |
887 | alpha channel data to an image which doesn't have any. If the pointer is not | |
888 | {\tt NULL}, it must have one byte for each image pixel and be allocated with | |
889 | {\tt malloc()}. wxImage takes ownership of the pointer and will free it. | |
890 | ||
891 | \func{void}{SetAlpha}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{alpha}} | |
892 | ||
893 | Sets the alpha value for the given pixel. This function should only be called | |
894 | if the image has alpha channel data, use \helpref{HasAlpha}{wximagehasalpha} to | |
895 | check for this. | |
896 | ||
1e6d9499 JS |
897 | \membersection{wxImage::SetData}\label{wximagesetdata} |
898 | ||
899 | \func{void}{SetData}{\param{unsigned char*}{data}} | |
900 | ||
f899db6d | 901 | Sets the image data without performing checks. The data given must have |
12a44087 RR |
902 | the size (width*height*3) or results will be unexpected. Don't use this |
903 | method if you aren't sure you know what you are doing. | |
1e6d9499 | 904 | |
b1ef8821 | 905 | The data must have been allocated with {\tt malloc()}, {\large {\bf NOT}} with |
487659e0 | 906 | {\tt operator new}. |
f811bc9a MB |
907 | |
908 | After this call the pointer to the data is owned by the wxImage object, | |
909 | that will be responsible for deleting it. | |
910 | Do not pass to this function a pointer obtained through | |
911 | \helpref{wxImage::GetData}{wximagegetdata}. | |
912 | ||
1e6d9499 JS |
913 | \membersection{wxImage::SetMask}\label{wximagesetmask} |
914 | ||
cc81d32f | 915 | \func{void}{SetMask}{\param{bool}{ hasMask = true}} |
1e6d9499 JS |
916 | |
917 | Specifies whether there is a mask or not. The area of the mask is determined by the current mask colour. | |
918 | ||
919 | \membersection{wxImage::SetMaskColour}\label{wximagesetmaskcolour} | |
920 | ||
80793cda | 921 | \func{void}{SetMaskColour}{\param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}} |
1e6d9499 | 922 | |
b1170810 | 923 | Sets the mask colour for this image (and tells the image to use the mask). |
1e6d9499 | 924 | |
37b83ca6 VS |
925 | \membersection{wxImage::SetMaskFromImage}\label{wximagesetmaskfromimage} |
926 | ||
927 | \func{bool}{SetMaskFromImage}{\param{const wxImage\&}{ mask}, \param{unsigned char}{ mr}, \param{unsigned char}{ mg}, \param{unsigned char}{ mb}} | |
928 | ||
929 | \wxheading{Parameters} | |
930 | ||
931 | \docparam{mask}{The mask image to extract mask shape from. Must have same dimensions as the image.} | |
932 | ||
933 | \docparam{mr,mg,mb}{RGB value of pixels in {\it mask} that will be used to create the mask.} | |
934 | ||
935 | Sets image's mask so that the pixels that have RGB value of {\it mr,mg,mb} | |
936 | in {\it mask} will be masked in the image. This is done by first finding an | |
937 | unused colour in the image, setting this colour as the mask colour and then | |
938 | using this colour to draw all pixels in the image who corresponding pixel | |
939 | in {\it mask} has given RGB value. | |
940 | ||
941 | \wxheading{Return value} | |
942 | ||
cc81d32f VS |
943 | Returns false if {\it mask} does not have same dimensions as the image or if |
944 | there is no unused colour left. Returns true if the mask was successfully | |
37b83ca6 VS |
945 | applied. |
946 | ||
947 | \wxheading{Notes} | |
948 | ||
949 | Note that this method involves computing the histogram, which is | |
950 | computationally intensive operation. | |
951 | ||
5e5437e0 JS |
952 | \membersection{wxImage::SetOption}\label{wximagesetoption} |
953 | ||
954 | \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{const wxString\&}{ value}} | |
955 | ||
956 | \func{void}{SetOption}{\param{const wxString\&}{ name}, \param{int}{ value}} | |
957 | ||
958 | Sets a user-defined option. The function is case-insensitive to {\it name}. | |
959 | ||
960 | For example, when saving as a JPEG file, the option {\bf quality} is | |
961 | used, which is a number between 0 and 100 (0 is terrible, 100 is very good). | |
962 | ||
963 | \wxheading{See also} | |
964 | ||
965 | \helpref{wxImage::GetOption}{wximagegetoption},\rtfsp | |
966 | \helpref{wxImage::GetOptionInt}{wximagegetoptionint},\rtfsp | |
967 | \helpref{wxImage::HasOption}{wximagehasoption} | |
968 | ||
3ca6a5f0 BP |
969 | \membersection{wxImage::SetPalette}\label{wximagesetpalette} |
970 | ||
971 | \func{void}{SetPalette}{\param{const wxPalette\&}{ palette}} | |
972 | ||
b06a6b20 VS |
973 | Associates a palette with the image. The palette may be used when converting |
974 | wxImage to wxBitmap (MSW only at present) or in file save operations (none as yet). | |
3ca6a5f0 | 975 | |
1e6d9499 JS |
976 | \membersection{wxImage::SetRGB}\label{wximagesetrgb} |
977 | ||
f6bcfd97 | 978 | \func{void}{SetRGB}{\param{int }{x}, \param{int }{y}, \param{unsigned char }{red}, \param{unsigned char }{green}, \param{unsigned char }{blue}} |
1e6d9499 | 979 | |
12a44087 RR |
980 | Sets the pixel at the given coordinate. This routine performs bounds-checks |
981 | for the coordinate so it can be considered a safe way to manipulate the | |
982 | data, but in some cases this might be too slow so that the data will have to | |
7468b994 RR |
983 | be set directly. In that case you will have to get access to the image data |
984 | using the \helpref{GetData}{wximagegetdata} method. | |
1e6d9499 JS |
985 | |
986 | \membersection{wxImage::operator $=$} | |
987 | ||
988 | \func{wxImage\& }{operator $=$}{\param{const wxImage\& }{image}} | |
989 | ||
990 | Assignment operator. This operator does not copy any data, but instead | |
991 | passes a pointer to the data in {\it image} and increments a reference | |
992 | counter. It is a fast operation. | |
993 | ||
994 | \wxheading{Parameters} | |
995 | ||
996 | \docparam{image}{Image to assign.} | |
997 | ||
998 | \wxheading{Return value} | |
999 | ||
1000 | Returns 'this' object. | |
1001 | ||
1002 | \membersection{wxImage::operator $==$} | |
1003 | ||
2b5f62a0 | 1004 | \constfunc{bool}{operator $==$}{\param{const wxImage\& }{image}} |
1e6d9499 JS |
1005 | |
1006 | Equality operator. This operator tests whether the internal data pointers are | |
1007 | equal (a fast test). | |
1008 | ||
1009 | \wxheading{Parameters} | |
1010 | ||
1011 | \docparam{image}{Image to compare with 'this'} | |
1012 | ||
1013 | \wxheading{Return value} | |
1014 | ||
cc81d32f | 1015 | Returns true if the images were effectively equal, false otherwise. |
1e6d9499 JS |
1016 | |
1017 | \membersection{wxImage::operator $!=$} | |
1018 | ||
2b5f62a0 | 1019 | \constfunc{bool}{operator $!=$}{\param{const wxImage\& }{image}} |
1e6d9499 JS |
1020 | |
1021 | Inequality operator. This operator tests whether the internal data pointers are | |
1022 | unequal (a fast test). | |
1023 | ||
1024 | \wxheading{Parameters} | |
1025 | ||
1026 | \docparam{image}{Image to compare with 'this'} | |
1027 | ||
1028 | \wxheading{Return value} | |
1029 | ||
cc81d32f | 1030 | Returns true if the images were unequal, false otherwise. |
1e6d9499 JS |
1031 | |
1032 | \section{\class{wxImageHandler}}\label{wximagehandler} | |
1033 | ||
1e6d9499 JS |
1034 | This is the base class for implementing image file loading/saving, and image creation from data. |
1035 | It is used within wxImage and is not normally seen by the application. | |
1036 | ||
1037 | If you wish to extend the capabilities of wxImage, derive a class from wxImageHandler | |
1038 | and add the handler using \helpref{wxImage::AddHandler}{wximageaddhandler} in your | |
1039 | application initialisation. | |
1040 | ||
48b4e302 VS |
1041 | \wxheading{Note (Legal Issue)} |
1042 | ||
954b8ae6 | 1043 | This software is based in part on the work of the Independent JPEG Group. |
48b4e302 VS |
1044 | |
1045 | (Applies when wxWindows is linked with JPEG support. wxJPEGHandler uses libjpeg | |
1046 | created by IJG.) | |
1047 | ||
1e6d9499 JS |
1048 | \wxheading{Derived from} |
1049 | ||
1050 | \helpref{wxObject}{wxobject} | |
1051 | ||
954b8ae6 JS |
1052 | \wxheading{Include files} |
1053 | ||
1054 | <wx/image.h> | |
1055 | ||
1e6d9499 JS |
1056 | \wxheading{See also} |
1057 | ||
fa482912 | 1058 | \helpref{wxImage}{wximage}, |
b5a4a47d | 1059 | \helpref{wxInitAllImageHandlers}{wxinitallimagehandlers} |
1e6d9499 JS |
1060 | |
1061 | \latexignore{\rtfignore{\wxheading{Members}}} | |
1062 | ||
1063 | \membersection{wxImageHandler::wxImageHandler}\label{wximagehandlerconstr} | |
1064 | ||
1065 | \func{}{wxImageHandler}{\void} | |
1066 | ||
1067 | Default constructor. In your own default constructor, initialise the members | |
1068 | m\_name, m\_extension and m\_type. | |
1069 | ||
1070 | \membersection{wxImageHandler::\destruct{wxImageHandler}} | |
1071 | ||
1072 | \func{}{\destruct{wxImageHandler}}{\void} | |
1073 | ||
1074 | Destroys the wxImageHandler object. | |
1075 | ||
1076 | \membersection{wxImageHandler::GetName} | |
1077 | ||
1078 | \constfunc{wxString}{GetName}{\void} | |
1079 | ||
1080 | Gets the name of this handler. | |
1081 | ||
1082 | \membersection{wxImageHandler::GetExtension} | |
1083 | ||
1084 | \constfunc{wxString}{GetExtension}{\void} | |
1085 | ||
1086 | Gets the file extension associated with this handler. | |
1087 | ||
649d13e8 | 1088 | \membersection{wxImageHandler::GetImageCount}\label{wximagehandlergetimagecount} |
7941ba11 | 1089 | |
649d13e8 | 1090 | \func{int}{GetImageCount}{\param{wxInputStream\&}{ stream}} |
7941ba11 RR |
1091 | |
1092 | If the image file contains more than one image and the image handler is capable | |
1093 | of retrieving these individually, this function will return the number of | |
1094 | available images. | |
1095 | ||
31fd9b6b | 1096 | \docparam{stream}{Opened input stream for reading image data. Currently, the stream must support seeking.} |
7941ba11 RR |
1097 | |
1098 | \wxheading{Return value} | |
1099 | ||
a61d25e6 VS |
1100 | Number of available images. For most image handlers, this is 1 (exceptions |
1101 | are TIFF and ICO formats). | |
7941ba11 | 1102 | |
1e6d9499 JS |
1103 | \membersection{wxImageHandler::GetType} |
1104 | ||
1105 | \constfunc{long}{GetType}{\void} | |
1106 | ||
1107 | Gets the image type associated with this handler. | |
1108 | ||
9e9ee68e VS |
1109 | \membersection{wxImageHandler::GetMimeType} |
1110 | ||
1111 | \constfunc{wxString}{GetMimeType}{\void} | |
1112 | ||
1113 | Gets the MIME type associated with this handler. | |
1114 | ||
1e6d9499 JS |
1115 | \membersection{wxImageHandler::LoadFile}\label{wximagehandlerloadfile} |
1116 | ||
cc81d32f | 1117 | \func{bool}{LoadFile}{\param{wxImage* }{image}, \param{wxInputStream\&}{ stream}, \param{bool}{ verbose=true}, \param{int}{ index=0}} |
1e6d9499 | 1118 | |
7941ba11 RR |
1119 | Loads a image from a stream, putting the resulting data into {\it image}. If the image file contains |
1120 | more than one image and the image handler is capable of retrieving these individually, {\it index} | |
1121 | indicates which image to read from the stream. | |
1e6d9499 JS |
1122 | |
1123 | \wxheading{Parameters} | |
1124 | ||
1125 | \docparam{image}{The image object which is to be affected by this operation.} | |
1126 | ||
31fd9b6b | 1127 | \docparam{stream}{Opened input stream for reading image data.} |
7941ba11 | 1128 | |
cc81d32f | 1129 | \docparam{verbose}{If set to true, errors reported by the image handler will produce wxLogMessages.} |
7941ba11 RR |
1130 | |
1131 | \docparam{index}{The index of the image in the file (starting from zero).} | |
1e6d9499 JS |
1132 | |
1133 | \wxheading{Return value} | |
1134 | ||
cc81d32f | 1135 | true if the operation succeeded, false otherwise. |
1e6d9499 JS |
1136 | |
1137 | \wxheading{See also} | |
1138 | ||
fa482912 JS |
1139 | \helpref{wxImage::LoadFile}{wximageloadfile}, |
1140 | \helpref{wxImage::SaveFile}{wximagesavefile}, | |
1e6d9499 JS |
1141 | \helpref{wxImageHandler::SaveFile}{wximagehandlersavefile} |
1142 | ||
1143 | \membersection{wxImageHandler::SaveFile}\label{wximagehandlersavefile} | |
1144 | ||
45b5751f | 1145 | \func{bool}{SaveFile}{\param{wxImage* }{image}, \param{wxOutputStream\& }{stream}} |
1e6d9499 | 1146 | |
45b5751f | 1147 | Saves a image in the output stream. |
1e6d9499 JS |
1148 | |
1149 | \wxheading{Parameters} | |
1150 | ||
1151 | \docparam{image}{The image object which is to be affected by this operation.} | |
1152 | ||
31fd9b6b | 1153 | \docparam{stream}{Opened output stream for writing the data.} |
1e6d9499 JS |
1154 | |
1155 | \wxheading{Return value} | |
1156 | ||
cc81d32f | 1157 | true if the operation succeeded, false otherwise. |
1e6d9499 JS |
1158 | |
1159 | \wxheading{See also} | |
1160 | ||
fa482912 JS |
1161 | \helpref{wxImage::LoadFile}{wximageloadfile}, |
1162 | \helpref{wxImage::SaveFile}{wximagesavefile}, | |
1e6d9499 JS |
1163 | \helpref{wxImageHandler::LoadFile}{wximagehandlerloadfile} |
1164 | ||
1165 | \membersection{wxImageHandler::SetName} | |
1166 | ||
1167 | \func{void}{SetName}{\param{const wxString\& }{name}} | |
1168 | ||
1169 | Sets the handler name. | |
1170 | ||
1171 | \wxheading{Parameters} | |
1172 | ||
1173 | \docparam{name}{Handler name.} | |
1174 | ||
1175 | \membersection{wxImageHandler::SetExtension} | |
1176 | ||
1177 | \func{void}{SetExtension}{\param{const wxString\& }{extension}} | |
1178 | ||
1179 | Sets the handler extension. | |
1180 | ||
1181 | \wxheading{Parameters} | |
1182 | ||
1183 | \docparam{extension}{Handler extension.} | |
1184 | ||
f6bcfd97 | 1185 | \membersection{wxImageHandler::SetMimeType}\label{wximagehandlersetmimetype} |
1e6d9499 | 1186 | |
f6bcfd97 | 1187 | \func{void}{SetMimeType}{\param{const wxString\& }{mimetype}} |
1e6d9499 | 1188 | |
f6bcfd97 | 1189 | Sets the handler MIME type. |
1e6d9499 JS |
1190 | |
1191 | \wxheading{Parameters} | |
1192 | ||
f6bcfd97 | 1193 | \docparam{mimename}{Handler MIME type.} |
9e9ee68e | 1194 | |
f6bcfd97 | 1195 | \membersection{wxImageHandler::SetType} |
9e9ee68e | 1196 | |
f6bcfd97 | 1197 | \func{void}{SetType}{\param{long }{type}} |
9e9ee68e | 1198 | |
f6bcfd97 | 1199 | Sets the handler type. |
9e9ee68e VS |
1200 | |
1201 | \wxheading{Parameters} | |
1202 | ||
f6bcfd97 | 1203 | \docparam{name}{Handler type.} |
9e9ee68e | 1204 |