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