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