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