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