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