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