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