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