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