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