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