]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: image.h | |
e54c96f1 | 3 | // Purpose: interface of wxImageHandler |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxImageHandler | |
11 | @wxheader{image.h} | |
7c913512 | 12 | |
23324ae1 FM |
13 | This is the base class for implementing image file loading/saving, and image |
14 | creation from data. | |
15 | It is used within wxImage and is not normally seen by the application. | |
7c913512 | 16 | |
23324ae1 FM |
17 | If you wish to extend the capabilities of wxImage, derive a class from |
18 | wxImageHandler | |
19 | and add the handler using wxImage::AddHandler in your | |
20 | application initialisation. | |
7c913512 | 21 | |
23324ae1 FM |
22 | @library{wxcore} |
23 | @category{FIXME} | |
7c913512 | 24 | |
e54c96f1 | 25 | @see wxImage, wxInitAllImageHandlers() |
23324ae1 FM |
26 | */ |
27 | class wxImageHandler : public wxObject | |
28 | { | |
29 | public: | |
30 | /** | |
31 | Default constructor. In your own default constructor, initialise the members | |
32 | m_name, m_extension and m_type. | |
33 | */ | |
34 | wxImageHandler(); | |
35 | ||
36 | /** | |
37 | Destroys the wxImageHandler object. | |
38 | */ | |
39 | ~wxImageHandler(); | |
40 | ||
41 | /** | |
42 | Gets the file extension associated with this handler. | |
43 | */ | |
328f5751 | 44 | const wxString GetExtension() const; |
23324ae1 FM |
45 | |
46 | /** | |
47 | If the image file contains more than one image and the image handler is capable | |
48 | of retrieving these individually, this function will return the number of | |
49 | available images. | |
3c4f71cc | 50 | |
7c913512 | 51 | @param stream |
4cc4bfaf FM |
52 | Opened input stream for reading image data. Currently, the stream must |
53 | support seeking. | |
3c4f71cc | 54 | |
23324ae1 | 55 | @returns Number of available images. For most image handlers, this is 1 |
4cc4bfaf | 56 | (exceptions are TIFF and ICO formats). |
23324ae1 FM |
57 | */ |
58 | int GetImageCount(wxInputStream& stream); | |
59 | ||
60 | /** | |
61 | Gets the MIME type associated with this handler. | |
62 | */ | |
328f5751 | 63 | const wxString GetMimeType() const; |
23324ae1 FM |
64 | |
65 | /** | |
66 | Gets the name of this handler. | |
67 | */ | |
328f5751 | 68 | const wxString GetName() const; |
23324ae1 FM |
69 | |
70 | /** | |
71 | Gets the image type associated with this handler. | |
72 | */ | |
328f5751 | 73 | long GetType() const; |
23324ae1 FM |
74 | |
75 | /** | |
76 | Loads a image from a stream, putting the resulting data into @e image. If the | |
77 | image file contains | |
78 | more than one image and the image handler is capable of retrieving these | |
79 | individually, @e index | |
80 | indicates which image to read from the stream. | |
3c4f71cc | 81 | |
7c913512 | 82 | @param image |
4cc4bfaf | 83 | The image object which is to be affected by this operation. |
7c913512 | 84 | @param stream |
4cc4bfaf | 85 | Opened input stream for reading image data. |
7c913512 | 86 | @param verbose |
4cc4bfaf FM |
87 | If set to @true, errors reported by the image handler will produce |
88 | wxLogMessages. | |
7c913512 | 89 | @param index |
4cc4bfaf | 90 | The index of the image in the file (starting from zero). |
3c4f71cc | 91 | |
23324ae1 | 92 | @returns @true if the operation succeeded, @false otherwise. |
3c4f71cc | 93 | |
4cc4bfaf | 94 | @see wxImage::LoadFile, wxImage::SaveFile, SaveFile() |
23324ae1 FM |
95 | */ |
96 | bool LoadFile(wxImage* image, wxInputStream& stream, | |
4cc4bfaf | 97 | bool verbose = true, int index = 0); |
23324ae1 FM |
98 | |
99 | /** | |
100 | Saves a image in the output stream. | |
3c4f71cc | 101 | |
7c913512 | 102 | @param image |
4cc4bfaf | 103 | The image object which is to be affected by this operation. |
7c913512 | 104 | @param stream |
4cc4bfaf | 105 | Opened output stream for writing the data. |
3c4f71cc | 106 | |
23324ae1 | 107 | @returns @true if the operation succeeded, @false otherwise. |
3c4f71cc | 108 | |
4cc4bfaf | 109 | @see wxImage::LoadFile, wxImage::SaveFile, LoadFile() |
23324ae1 FM |
110 | */ |
111 | bool SaveFile(wxImage* image, wxOutputStream& stream); | |
112 | ||
113 | /** | |
114 | Sets the handler extension. | |
3c4f71cc | 115 | |
7c913512 | 116 | @param extension |
4cc4bfaf | 117 | Handler extension. |
23324ae1 FM |
118 | */ |
119 | void SetExtension(const wxString& extension); | |
120 | ||
121 | /** | |
122 | Sets the handler MIME type. | |
3c4f71cc | 123 | |
7c913512 | 124 | @param mimename |
4cc4bfaf | 125 | Handler MIME type. |
23324ae1 FM |
126 | */ |
127 | void SetMimeType(const wxString& mimetype); | |
128 | ||
129 | /** | |
130 | Sets the handler name. | |
3c4f71cc | 131 | |
7c913512 | 132 | @param name |
4cc4bfaf | 133 | Handler name. |
23324ae1 FM |
134 | */ |
135 | void SetName(const wxString& name); | |
136 | }; | |
137 | ||
138 | ||
e54c96f1 | 139 | |
23324ae1 FM |
140 | /** |
141 | @class wxImage | |
142 | @wxheader{image.h} | |
7c913512 | 143 | |
23324ae1 FM |
144 | This class encapsulates a platform-independent image. An image can be created |
145 | from data, or using wxBitmap::ConvertToImage. An image | |
146 | can be loaded from a file in a variety of formats, and is extensible to new | |
147 | formats | |
148 | via image format handlers. Functions are available to set and get image bits, so | |
149 | it can be used for basic image manipulation. | |
7c913512 | 150 | |
23324ae1 FM |
151 | A wxImage cannot (currently) be drawn directly to a wxDC. Instead, |
152 | a platform-specific wxBitmap object must be created from it using | |
153 | the wxBitmap::wxBitmap(wxImage,int depth) constructor. | |
154 | This bitmap can then | |
155 | be drawn in a device context, using wxDC::DrawBitmap. | |
7c913512 | 156 | |
23324ae1 | 157 | One colour value of the image may be used as a mask colour which will lead to |
65874118 | 158 | the automatic creation of a wxMask object associated to the bitmap object. |
7c913512 | 159 | |
23324ae1 FM |
160 | @library{wxcore} |
161 | @category{gdi} | |
7c913512 | 162 | |
65874118 FM |
163 | @stdobjects |
164 | ::wxNullImage | |
165 | ||
e54c96f1 | 166 | @see wxBitmap, wxInitAllImageHandlers() |
23324ae1 FM |
167 | */ |
168 | class wxImage : public wxObject | |
169 | { | |
170 | public: | |
171 | //@{ | |
172 | /** | |
173 | Creates an image from XPM data. | |
3c4f71cc | 174 | |
7c913512 | 175 | @param width |
4cc4bfaf | 176 | Specifies the width of the image. |
7c913512 | 177 | @param height |
4cc4bfaf | 178 | Specifies the height of the image. |
7c913512 | 179 | @param name |
4cc4bfaf | 180 | Name of the file from which to load the image. |
7c913512 | 181 | @param stream |
4cc4bfaf FM |
182 | Opened input stream from which to load the image. Currently, the stream |
183 | must support seeking. | |
7c913512 | 184 | @param type |
4cc4bfaf | 185 | May be one of the following: |
3c4f71cc VS |
186 | |
187 | ||
188 | ||
189 | ||
190 | ||
191 | ||
4cc4bfaf | 192 | wxBITMAP_TYPE_BMP |
3c4f71cc VS |
193 | |
194 | ||
195 | ||
196 | ||
4cc4bfaf | 197 | Load a Windows bitmap file. |
3c4f71cc VS |
198 | |
199 | ||
200 | ||
201 | ||
202 | ||
4cc4bfaf | 203 | wxBITMAP_TYPE_GIF |
3c4f71cc VS |
204 | |
205 | ||
206 | ||
207 | ||
4cc4bfaf | 208 | Load a GIF bitmap file. |
3c4f71cc VS |
209 | |
210 | ||
211 | ||
212 | ||
213 | ||
4cc4bfaf | 214 | wxBITMAP_TYPE_JPEG |
3c4f71cc VS |
215 | |
216 | ||
217 | ||
218 | ||
4cc4bfaf | 219 | Load a JPEG bitmap file. |
3c4f71cc VS |
220 | |
221 | ||
222 | ||
223 | ||
224 | ||
4cc4bfaf | 225 | wxBITMAP_TYPE_PNG |
3c4f71cc VS |
226 | |
227 | ||
228 | ||
229 | ||
4cc4bfaf | 230 | Load a PNG bitmap file. |
3c4f71cc VS |
231 | |
232 | ||
233 | ||
234 | ||
235 | ||
4cc4bfaf | 236 | wxBITMAP_TYPE_PCX |
3c4f71cc VS |
237 | |
238 | ||
239 | ||
240 | ||
4cc4bfaf | 241 | Load a PCX bitmap file. |
3c4f71cc VS |
242 | |
243 | ||
244 | ||
245 | ||
246 | ||
4cc4bfaf | 247 | wxBITMAP_TYPE_PNM |
3c4f71cc VS |
248 | |
249 | ||
250 | ||
251 | ||
4cc4bfaf | 252 | Load a PNM bitmap file. |
3c4f71cc VS |
253 | |
254 | ||
255 | ||
256 | ||
257 | ||
4cc4bfaf | 258 | wxBITMAP_TYPE_TIF |
3c4f71cc VS |
259 | |
260 | ||
261 | ||
262 | ||
4cc4bfaf | 263 | Load a TIFF bitmap file. |
3c4f71cc VS |
264 | |
265 | ||
266 | ||
267 | ||
268 | ||
4cc4bfaf | 269 | wxBITMAP_TYPE_TGA |
3c4f71cc VS |
270 | |
271 | ||
272 | ||
273 | ||
4cc4bfaf | 274 | Load a TGA bitmap file. |
3c4f71cc VS |
275 | |
276 | ||
277 | ||
278 | ||
279 | ||
4cc4bfaf | 280 | wxBITMAP_TYPE_XPM |
3c4f71cc VS |
281 | |
282 | ||
283 | ||
284 | ||
4cc4bfaf | 285 | Load a XPM bitmap file. |
3c4f71cc VS |
286 | |
287 | ||
288 | ||
289 | ||
290 | ||
4cc4bfaf | 291 | wxBITMAP_TYPE_ICO |
3c4f71cc VS |
292 | |
293 | ||
294 | ||
295 | ||
4cc4bfaf | 296 | Load a Windows icon file (ICO). |
3c4f71cc VS |
297 | |
298 | ||
299 | ||
300 | ||
301 | ||
4cc4bfaf | 302 | wxBITMAP_TYPE_CUR |
3c4f71cc VS |
303 | |
304 | ||
305 | ||
306 | ||
4cc4bfaf | 307 | Load a Windows cursor file (CUR). |
3c4f71cc VS |
308 | |
309 | ||
310 | ||
311 | ||
312 | ||
4cc4bfaf | 313 | wxBITMAP_TYPE_ANI |
3c4f71cc VS |
314 | |
315 | ||
316 | ||
317 | ||
4cc4bfaf | 318 | Load a Windows animated cursor file (ANI). |
3c4f71cc VS |
319 | |
320 | ||
321 | ||
322 | ||
323 | ||
4cc4bfaf | 324 | wxBITMAP_TYPE_ANY |
3c4f71cc VS |
325 | |
326 | ||
327 | ||
328 | ||
4cc4bfaf FM |
329 | Will try to autodetect the format. |
330 | @param mimetype | |
331 | MIME type string (for example 'image/jpeg') | |
332 | @param index | |
333 | Index of the image to load in the case that the image file contains | |
334 | multiple images. | |
335 | This is only used by GIF, ICO and TIFF handlers. The default value (-1) | |
336 | means | |
337 | "choose the default image" and is interpreted as the first image (index=0) | |
338 | by | |
339 | the GIF and TIFF handler and as the largest and most colourful one by the | |
340 | ICO handler. | |
7c913512 | 341 | @param xpmData |
4cc4bfaf | 342 | A pointer to XPM image data. |
3c4f71cc | 343 | |
23324ae1 | 344 | @remarks Depending on how wxWidgets has been configured, not all formats |
4cc4bfaf | 345 | may be available. |
3c4f71cc | 346 | |
4cc4bfaf | 347 | @see LoadFile() |
23324ae1 FM |
348 | */ |
349 | wxImage(); | |
7c913512 FM |
350 | wxImage(const wxImage& image); |
351 | wxImage(const wxBitmap& bitmap); | |
4cc4bfaf | 352 | wxImage(int width, int height, bool clear = true); |
7c913512 | 353 | wxImage(int width, int height, unsigned char* data, |
4cc4bfaf | 354 | bool static_data = false); |
7c913512 FM |
355 | wxImage(const wxString& name, long type = wxBITMAP_TYPE_ANY, |
356 | int index = -1); | |
357 | wxImage(const wxString& name, const wxString& mimetype, | |
358 | int index = -1); | |
359 | wxImage(wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, | |
360 | int index = -1); | |
361 | wxImage(wxInputStream& stream, const wxString& mimetype, | |
362 | int index = -1); | |
363 | wxImage(const char* const* xpmData); | |
23324ae1 FM |
364 | //@} |
365 | ||
366 | /** | |
367 | Destructor. | |
368 | See @ref overview_refcountdestruct "reference-counted object destruction" for | |
369 | more info. | |
370 | */ | |
371 | ~wxImage(); | |
372 | ||
373 | //@{ | |
374 | /** | |
375 | returns @true if the current image handlers can read this file | |
376 | */ | |
377 | static void AddHandler(wxImageHandler* handler); | |
7c913512 | 378 | See also bool CanRead(const wxString& filename); |
23324ae1 FM |
379 | //@} |
380 | ||
381 | /** | |
382 | Blurs the image in both horizontal and vertical directions by the specified | |
383 | pixel | |
384 | @e blurRadius. This should not be used when using a single mask colour | |
385 | for transparency. | |
3c4f71cc | 386 | |
4cc4bfaf | 387 | @see @ref horzblur() BlurHorizontal, @ref vertblur() BlurVertical |
23324ae1 FM |
388 | */ |
389 | wxImage Blur(int blurRadius); | |
390 | ||
391 | /** | |
392 | Blurs the image in the horizontal direction only. This should not be used | |
393 | when using a single mask colour for transparency. | |
3c4f71cc | 394 | |
4cc4bfaf | 395 | @see Blur(), @ref vertblur() BlurVertical |
23324ae1 FM |
396 | */ |
397 | wxImage BlurHorizontal(int blurRadius); | |
398 | ||
399 | /** | |
400 | Blurs the image in the vertical direction only. This should not be used | |
401 | when using a single mask colour for transparency. | |
3c4f71cc | 402 | |
4cc4bfaf | 403 | @see Blur(), @ref horzblur() BlurHorizontal |
23324ae1 FM |
404 | */ |
405 | wxImage BlurVertical(int blurRadius); | |
406 | ||
407 | /** | |
408 | Deletes all image handlers. | |
23324ae1 FM |
409 | This function is called by wxWidgets on exit. |
410 | */ | |
411 | static void CleanUpHandlers(); | |
412 | ||
413 | /** | |
4cc4bfaf | 414 | Computes the histogram of the image. @a histogram is a reference to |
23324ae1 FM |
415 | wxImageHistogram object. wxImageHistogram is a specialization of |
416 | wxHashMap "template" and is defined as follows: | |
3c4f71cc | 417 | |
23324ae1 FM |
418 | @returns Returns number of colours in the histogram. |
419 | */ | |
328f5751 | 420 | unsigned long ComputeHistogram(wxImageHistogram& histogram) const; |
23324ae1 FM |
421 | |
422 | /** | |
423 | If the image has alpha channel, this method converts it to mask. All pixels | |
4cc4bfaf | 424 | with alpha value less than @a threshold are replaced with mask colour |
23324ae1 FM |
425 | and the alpha channel is removed. Mask colour is chosen automatically using |
426 | FindFirstUnusedColour(). | |
23324ae1 FM |
427 | If the image image doesn't have alpha channel, |
428 | ConvertAlphaToMask does nothing. | |
3c4f71cc | 429 | |
23324ae1 FM |
430 | @returns @false if FindFirstUnusedColour returns @false, @true otherwise. |
431 | */ | |
432 | bool ConvertAlphaToMask(unsigned char threshold = 128); | |
433 | ||
434 | /** | |
435 | Deprecated, use equivalent @ref wxBitmap::ctor "wxBitmap constructor" | |
436 | (which takes wxImage and depth as its arguments) instead. | |
437 | */ | |
328f5751 | 438 | wxBitmap ConvertToBitmap() const; |
23324ae1 FM |
439 | |
440 | /** | |
441 | Returns a greyscale version of the image. The returned image uses the luminance | |
442 | component of the original to calculate the greyscale. Defaults to using | |
443 | ITU-T BT.601 when converting to YUV, where every pixel equals | |
444 | (R * @e lr) + (G * @e lg) + (B * @e lb). | |
445 | */ | |
446 | wxImage ConvertToGreyscale(double lr = 0.299, double lg = 0.587, | |
328f5751 | 447 | double lb = 0.114) const; |
23324ae1 FM |
448 | |
449 | /** | |
450 | Returns monochromatic version of the image. The returned image has white | |
451 | colour where the original has @e (r,g,b) colour and black colour | |
452 | everywhere else. | |
453 | */ | |
454 | wxImage ConvertToMono(unsigned char r, unsigned char g, | |
328f5751 | 455 | unsigned char b) const; |
23324ae1 FM |
456 | |
457 | /** | |
458 | Returns an identical copy of the image. | |
459 | */ | |
328f5751 | 460 | wxImage Copy() const; |
23324ae1 FM |
461 | |
462 | /** | |
4cc4bfaf | 463 | Creates a fresh image. If @a clear is @true, the new image will be initialized |
23324ae1 FM |
464 | to black. |
465 | Otherwise, the image data will be uninitialized. | |
3c4f71cc | 466 | |
7c913512 | 467 | @param width |
4cc4bfaf | 468 | The width of the image in pixels. |
7c913512 | 469 | @param height |
4cc4bfaf | 470 | The height of the image in pixels. |
3c4f71cc | 471 | |
23324ae1 FM |
472 | @returns @true if the call succeeded, @false otherwise. |
473 | */ | |
4cc4bfaf | 474 | bool Create(int width, int height, bool clear = true); |
23324ae1 FM |
475 | |
476 | /** | |
477 | Destroys the image data. | |
478 | */ | |
479 | void Destroy(); | |
480 | ||
481 | /** | |
7c913512 | 482 | @param r,g,b |
4cc4bfaf | 483 | Pointers to variables to save the colour. |
7c913512 | 484 | @param startR,startG,startB |
4cc4bfaf FM |
485 | Initial values of the colour. Returned colour |
486 | will have RGB values equal to or greater than these. | |
3c4f71cc | 487 | |
23324ae1 FM |
488 | @returns Returns @false if there is no unused colour left, @true on success. |
489 | */ | |
4cc4bfaf FM |
490 | bool FindFirstUnusedColour(unsigned char* r, unsigned char* g, |
491 | unsigned char* b, | |
23324ae1 FM |
492 | unsigned char startR = 1, |
493 | unsigned char startG = 0, | |
494 | unsigned char startB = 0); | |
495 | ||
496 | //@{ | |
497 | /** | |
498 | Finds the handler associated with the given MIME type. | |
3c4f71cc | 499 | |
7c913512 | 500 | @param name |
4cc4bfaf | 501 | The handler name. |
7c913512 | 502 | @param extension |
4cc4bfaf | 503 | The file extension, such as "bmp". |
7c913512 | 504 | @param imageType |
4cc4bfaf | 505 | The image type, such as wxBITMAP_TYPE_BMP. |
7c913512 | 506 | @param mimetype |
4cc4bfaf | 507 | MIME type. |
3c4f71cc | 508 | |
23324ae1 | 509 | @returns A pointer to the handler if found, @NULL otherwise. |
3c4f71cc | 510 | |
4cc4bfaf | 511 | @see wxImageHandler |
23324ae1 FM |
512 | */ |
513 | static wxImageHandler* FindHandler(const wxString& name); | |
7c913512 FM |
514 | static wxImageHandler* FindHandler(const wxString& extension, |
515 | long imageType); | |
516 | static wxImageHandler* FindHandler(long imageType); | |
517 | static wxImageHandler* FindHandlerMime(const wxString& mimetype); | |
23324ae1 FM |
518 | //@} |
519 | ||
520 | //@{ | |
521 | /** | |
522 | Returns pointer to the array storing the alpha values for this image. This | |
523 | pointer is @NULL for the images without the alpha channel. If the image | |
524 | does have it, this pointer may be used to directly manipulate the alpha values | |
525 | which are stored as the @ref getdata() RGB ones. | |
526 | */ | |
328f5751 FM |
527 | unsigned char GetAlpha(int x, int y) const; |
528 | const unsigned char * GetAlpha() const; | |
23324ae1 FM |
529 | //@} |
530 | ||
531 | /** | |
532 | Returns the blue intensity at the given coordinate. | |
533 | */ | |
328f5751 | 534 | unsigned char GetBlue(int x, int y) const; |
23324ae1 FM |
535 | |
536 | /** | |
537 | Returns the image data as an array. This is most often used when doing | |
538 | direct image manipulation. The return value points to an array of | |
539 | characters in RGBRGBRGB... format in the top-to-bottom, left-to-right | |
540 | order, that is the first RGB triplet corresponds to the pixel first pixel of | |
541 | the first row, the second one --- to the second pixel of the first row and so | |
542 | on until the end of the first row, with second row following after it and so | |
543 | on. | |
23324ae1 FM |
544 | You should not delete the returned pointer nor pass it to |
545 | SetData(). | |
546 | */ | |
328f5751 | 547 | unsigned char* GetData() const; |
23324ae1 FM |
548 | |
549 | /** | |
550 | Returns the green intensity at the given coordinate. | |
551 | */ | |
328f5751 | 552 | unsigned char GetGreen(int x, int y) const; |
23324ae1 FM |
553 | |
554 | /** | |
555 | Returns the static list of image format handlers. | |
3c4f71cc | 556 | |
4cc4bfaf | 557 | @see wxImageHandler |
23324ae1 FM |
558 | */ |
559 | static wxList GetHandlers(); | |
560 | ||
561 | /** | |
562 | Gets the height of the image in pixels. | |
563 | */ | |
328f5751 | 564 | int GetHeight() const; |
23324ae1 FM |
565 | |
566 | //@{ | |
567 | /** | |
568 | If the image file contains more than one image and the image handler is capable | |
569 | of retrieving these individually, this function will return the number of | |
570 | available images. | |
3c4f71cc | 571 | |
7c913512 | 572 | @param name |
4cc4bfaf | 573 | Name of the file to query. |
7c913512 | 574 | @param stream |
4cc4bfaf FM |
575 | Opened input stream with image data. Currently, the stream must support |
576 | seeking. | |
7c913512 | 577 | @param type |
4cc4bfaf | 578 | May be one of the following: |
3c4f71cc VS |
579 | |
580 | ||
581 | ||
582 | ||
583 | ||
584 | ||
4cc4bfaf | 585 | wxBITMAP_TYPE_BMP |
3c4f71cc VS |
586 | |
587 | ||
588 | ||
589 | ||
4cc4bfaf | 590 | Load a Windows bitmap file. |
3c4f71cc VS |
591 | |
592 | ||
593 | ||
594 | ||
595 | ||
4cc4bfaf | 596 | wxBITMAP_TYPE_GIF |
3c4f71cc VS |
597 | |
598 | ||
599 | ||
600 | ||
4cc4bfaf | 601 | Load a GIF bitmap file. |
3c4f71cc VS |
602 | |
603 | ||
604 | ||
605 | ||
606 | ||
4cc4bfaf | 607 | wxBITMAP_TYPE_JPEG |
3c4f71cc VS |
608 | |
609 | ||
610 | ||
611 | ||
4cc4bfaf | 612 | Load a JPEG bitmap file. |
3c4f71cc VS |
613 | |
614 | ||
615 | ||
616 | ||
617 | ||
4cc4bfaf | 618 | wxBITMAP_TYPE_PNG |
3c4f71cc VS |
619 | |
620 | ||
621 | ||
622 | ||
4cc4bfaf | 623 | Load a PNG bitmap file. |
3c4f71cc VS |
624 | |
625 | ||
626 | ||
627 | ||
628 | ||
4cc4bfaf | 629 | wxBITMAP_TYPE_PCX |
3c4f71cc VS |
630 | |
631 | ||
632 | ||
633 | ||
4cc4bfaf | 634 | Load a PCX bitmap file. |
3c4f71cc VS |
635 | |
636 | ||
637 | ||
638 | ||
639 | ||
4cc4bfaf | 640 | wxBITMAP_TYPE_PNM |
3c4f71cc VS |
641 | |
642 | ||
643 | ||
644 | ||
4cc4bfaf | 645 | Load a PNM bitmap file. |
3c4f71cc VS |
646 | |
647 | ||
648 | ||
649 | ||
650 | ||
4cc4bfaf | 651 | wxBITMAP_TYPE_TIF |
3c4f71cc VS |
652 | |
653 | ||
654 | ||
655 | ||
4cc4bfaf | 656 | Load a TIFF bitmap file. |
3c4f71cc VS |
657 | |
658 | ||
659 | ||
660 | ||
661 | ||
4cc4bfaf | 662 | wxBITMAP_TYPE_XPM |
3c4f71cc VS |
663 | |
664 | ||
665 | ||
666 | ||
4cc4bfaf | 667 | Load a XPM bitmap file. |
3c4f71cc VS |
668 | |
669 | ||
670 | ||
671 | ||
672 | ||
4cc4bfaf | 673 | wxBITMAP_TYPE_ICO |
3c4f71cc VS |
674 | |
675 | ||
676 | ||
677 | ||
4cc4bfaf | 678 | Load a Windows icon file (ICO). |
3c4f71cc VS |
679 | |
680 | ||
681 | ||
682 | ||
683 | ||
4cc4bfaf | 684 | wxBITMAP_TYPE_CUR |
3c4f71cc VS |
685 | |
686 | ||
687 | ||
688 | ||
4cc4bfaf | 689 | Load a Windows cursor file (CUR). |
3c4f71cc VS |
690 | |
691 | ||
692 | ||
693 | ||
694 | ||
4cc4bfaf | 695 | wxBITMAP_TYPE_ANI |
3c4f71cc VS |
696 | |
697 | ||
698 | ||
699 | ||
4cc4bfaf | 700 | Load a Windows animated cursor file (ANI). |
3c4f71cc VS |
701 | |
702 | ||
703 | ||
704 | ||
705 | ||
4cc4bfaf | 706 | wxBITMAP_TYPE_ANY |
3c4f71cc VS |
707 | |
708 | ||
709 | ||
710 | ||
4cc4bfaf | 711 | Will try to autodetect the format. |
3c4f71cc | 712 | |
23324ae1 | 713 | @returns Number of available images. For most image handlers, this is 1 |
4cc4bfaf | 714 | (exceptions are TIFF and ICO formats). |
23324ae1 FM |
715 | */ |
716 | static int GetImageCount(const wxString& filename, | |
717 | long type = wxBITMAP_TYPE_ANY); | |
7c913512 FM |
718 | static int GetImageCount(wxInputStream& stream, |
719 | long type = wxBITMAP_TYPE_ANY); | |
23324ae1 FM |
720 | //@} |
721 | ||
722 | /** | |
723 | Iterates all registered wxImageHandler objects, and returns a string containing | |
724 | file extension masks | |
725 | suitable for passing to file open/save dialog boxes. | |
3c4f71cc | 726 | |
23324ae1 | 727 | @returns The format of the returned string is |
4cc4bfaf | 728 | "(*.ext1;*.ext2)|*.ext1;*.ext2". |
3c4f71cc | 729 | |
4cc4bfaf | 730 | @see wxImageHandler |
23324ae1 FM |
731 | */ |
732 | static wxString GetImageExtWildcard(); | |
733 | ||
734 | /** | |
735 | Gets the blue value of the mask colour. | |
736 | */ | |
328f5751 | 737 | unsigned char GetMaskBlue() const; |
23324ae1 FM |
738 | |
739 | /** | |
740 | Gets the green value of the mask colour. | |
741 | */ | |
328f5751 | 742 | unsigned char GetMaskGreen() const; |
23324ae1 FM |
743 | |
744 | /** | |
745 | Gets the red value of the mask colour. | |
746 | */ | |
328f5751 | 747 | unsigned char GetMaskRed() const; |
23324ae1 FM |
748 | |
749 | /** | |
750 | Gets a user-defined option. The function is case-insensitive to @e name. | |
23324ae1 FM |
751 | For example, when saving as a JPEG file, the option @b quality is |
752 | used, which is a number between 0 and 100 (0 is terrible, 100 is very good). | |
3c4f71cc | 753 | |
4cc4bfaf | 754 | @see SetOption(), GetOptionInt(), HasOption() |
23324ae1 | 755 | */ |
328f5751 | 756 | wxString GetOption(const wxString& name) const; |
23324ae1 FM |
757 | |
758 | /** | |
759 | Gets a user-defined option as an integer. The function is case-insensitive to | |
760 | @e name. | |
23324ae1 FM |
761 | If the given option is not present, the function returns 0. Use |
762 | HasOption() is 0 is a possibly valid value | |
763 | for the option. | |
23324ae1 | 764 | Options for wxPNGHandler |
3c4f71cc | 765 | |
23324ae1 | 766 | wxIMAGE_OPTION_PNG_FORMAT |
3c4f71cc | 767 | |
23324ae1 | 768 | Format for saving a PNG file. |
3c4f71cc | 769 | |
23324ae1 | 770 | wxIMAGE_OPTION_PNG_BITDEPTH |
3c4f71cc | 771 | |
23324ae1 | 772 | Bit depth for every channel (R/G/B/A). |
3c4f71cc | 773 | |
23324ae1 | 774 | Supported values for wxIMAGE_OPTION_PNG_FORMAT: |
3c4f71cc | 775 | |
23324ae1 | 776 | wxPNG_TYPE_COLOUR |
3c4f71cc | 777 | |
23324ae1 | 778 | Stores RGB image. |
3c4f71cc | 779 | |
23324ae1 | 780 | wxPNG_TYPE_GREY |
3c4f71cc | 781 | |
23324ae1 | 782 | Stores grey image, converts from RGB. |
3c4f71cc | 783 | |
23324ae1 | 784 | wxPNG_TYPE_GREY_RED |
3c4f71cc | 785 | |
23324ae1 | 786 | Stores grey image, uses red value as grey. |
3c4f71cc | 787 | |
4cc4bfaf | 788 | @see SetOption(), GetOption() |
23324ae1 | 789 | */ |
328f5751 | 790 | int GetOptionInt(const wxString& name) const; |
23324ae1 FM |
791 | |
792 | /** | |
793 | Get the current mask colour or find a suitable unused colour that could be | |
794 | used as a mask colour. Returns @true if the image currently has a mask. | |
795 | */ | |
796 | bool GetOrFindMaskColour(unsigned char r, unsigned char g, | |
328f5751 | 797 | unsigned char b) const; |
23324ae1 FM |
798 | |
799 | /** | |
800 | Returns the palette associated with the image. Currently the palette is only | |
801 | used when converting to wxBitmap under Windows. Some of the wxImage handlers | |
802 | have been modified to set the palette if one exists in the image file (usually | |
803 | 256 or less colour images in GIF or PNG format). | |
804 | */ | |
328f5751 | 805 | const wxPalette GetPalette() const; |
23324ae1 FM |
806 | |
807 | /** | |
808 | Returns the red intensity at the given coordinate. | |
809 | */ | |
328f5751 | 810 | unsigned char GetRed(int x, int y) const; |
23324ae1 FM |
811 | |
812 | /** | |
813 | Returns a sub image of the current one as long as the rect belongs entirely to | |
814 | the image. | |
815 | */ | |
328f5751 | 816 | wxImage GetSubImage(const wxRect& rect) const; |
23324ae1 FM |
817 | |
818 | /** | |
819 | Gets the width of the image in pixels. | |
3c4f71cc | 820 | |
4cc4bfaf | 821 | @see GetHeight() |
23324ae1 | 822 | */ |
328f5751 | 823 | int GetWidth() const; |
23324ae1 FM |
824 | |
825 | /** | |
826 | Constructor for HSVValue, an object that contains values for hue, saturation | |
827 | and value which | |
828 | represent the value of a color. It is used by HSVtoRGB() | |
829 | and RGBtoHSV(), which | |
830 | converts between HSV color space and RGB color space. | |
831 | */ | |
7c913512 | 832 | HSVValue(double h = 0.0, double s = 0.0, double v = 0.0); |
23324ae1 FM |
833 | |
834 | /** | |
835 | Converts a color in HSV color space to RGB color space. | |
836 | */ | |
4cc4bfaf | 837 | #define wxImage::RGBValue HSVtoRGB(const HSVValue& hsv) /* implementation is private */ |
23324ae1 FM |
838 | |
839 | /** | |
840 | Returns @true if this image has alpha channel, @false otherwise. | |
3c4f71cc | 841 | |
4cc4bfaf | 842 | @see GetAlpha(), SetAlpha() |
23324ae1 | 843 | */ |
328f5751 | 844 | bool HasAlpha() const; |
23324ae1 FM |
845 | |
846 | /** | |
847 | Returns @true if there is a mask active, @false otherwise. | |
848 | */ | |
328f5751 | 849 | bool HasMask() const; |
23324ae1 FM |
850 | |
851 | /** | |
852 | Returns @true if the given option is present. The function is case-insensitive | |
853 | to @e name. | |
3c4f71cc | 854 | |
4cc4bfaf | 855 | @see SetOption(), GetOption(), GetOptionInt() |
23324ae1 | 856 | */ |
328f5751 | 857 | bool HasOption(const wxString& name) const; |
23324ae1 FM |
858 | |
859 | /** | |
860 | Initializes the image alpha channel data. It is an error to call it | |
861 | if the image already has alpha data. If it doesn't, alpha data will be | |
862 | by default initialized to all pixels being fully opaque. But if the image has a | |
863 | a mask colour, all mask pixels will be completely transparent. | |
864 | */ | |
865 | void InitAlpha(); | |
866 | ||
867 | /** | |
868 | Internal use only. Adds standard image format handlers. It only install BMP | |
869 | for the time being, which is used by wxBitmap. | |
23324ae1 FM |
870 | This function is called by wxWidgets on startup, and shouldn't be called by |
871 | the user. | |
3c4f71cc | 872 | |
e54c96f1 | 873 | @see wxImageHandler, wxInitAllImageHandlers(), wxQuantize |
23324ae1 FM |
874 | */ |
875 | static void InitStandardHandlers(); | |
876 | ||
877 | /** | |
878 | Adds a handler at the start of the static list of format handlers. | |
3c4f71cc | 879 | |
7c913512 | 880 | @param handler |
4cc4bfaf FM |
881 | A new image format handler object. There is usually only one instance |
882 | of a given handler class in an application session. | |
3c4f71cc | 883 | |
4cc4bfaf | 884 | @see wxImageHandler |
23324ae1 FM |
885 | */ |
886 | static void InsertHandler(wxImageHandler* handler); | |
887 | ||
888 | /** | |
889 | Returns @true if image data is present. | |
890 | */ | |
328f5751 | 891 | bool IsOk() const; |
23324ae1 FM |
892 | |
893 | /** | |
894 | Returns @true if the given pixel is transparent, i.e. either has the mask | |
895 | colour if this image has a mask or if this image has alpha channel and alpha | |
896 | value of this pixel is strictly less than @e threshold. | |
897 | */ | |
328f5751 | 898 | bool IsTransparent(int x, int y, unsigned char threshold = 128) const; |
23324ae1 FM |
899 | |
900 | //@{ | |
901 | /** | |
902 | Loads an image from an input stream. | |
3c4f71cc | 903 | |
7c913512 | 904 | @param name |
4cc4bfaf | 905 | Name of the file from which to load the image. |
7c913512 | 906 | @param stream |
4cc4bfaf FM |
907 | Opened input stream from which to load the image. Currently, the stream |
908 | must support seeking. | |
7c913512 | 909 | @param type |
4cc4bfaf | 910 | One of the following values: |
3c4f71cc VS |
911 | |
912 | ||
913 | ||
914 | ||
915 | ||
916 | ||
4cc4bfaf | 917 | wxBITMAP_TYPE_BMP |
3c4f71cc VS |
918 | |
919 | ||
920 | ||
921 | ||
4cc4bfaf | 922 | Load a Windows image file. |
3c4f71cc VS |
923 | |
924 | ||
925 | ||
926 | ||
927 | ||
4cc4bfaf | 928 | wxBITMAP_TYPE_GIF |
3c4f71cc VS |
929 | |
930 | ||
931 | ||
932 | ||
4cc4bfaf | 933 | Load a GIF image file. |
3c4f71cc VS |
934 | |
935 | ||
936 | ||
937 | ||
938 | ||
4cc4bfaf | 939 | wxBITMAP_TYPE_JPEG |
3c4f71cc VS |
940 | |
941 | ||
942 | ||
943 | ||
4cc4bfaf | 944 | Load a JPEG image file. |
3c4f71cc VS |
945 | |
946 | ||
947 | ||
948 | ||
949 | ||
4cc4bfaf | 950 | wxBITMAP_TYPE_PCX |
3c4f71cc VS |
951 | |
952 | ||
953 | ||
954 | ||
4cc4bfaf | 955 | Load a PCX image file. |
3c4f71cc VS |
956 | |
957 | ||
958 | ||
959 | ||
960 | ||
4cc4bfaf | 961 | wxBITMAP_TYPE_PNG |
3c4f71cc VS |
962 | |
963 | ||
964 | ||
965 | ||
4cc4bfaf | 966 | Load a PNG image file. |
3c4f71cc VS |
967 | |
968 | ||
969 | ||
970 | ||
971 | ||
4cc4bfaf | 972 | wxBITMAP_TYPE_PNM |
3c4f71cc VS |
973 | |
974 | ||
975 | ||
976 | ||
4cc4bfaf | 977 | Load a PNM image file. |
3c4f71cc VS |
978 | |
979 | ||
980 | ||
981 | ||
982 | ||
4cc4bfaf | 983 | wxBITMAP_TYPE_TIF |
3c4f71cc VS |
984 | |
985 | ||
986 | ||
987 | ||
4cc4bfaf | 988 | Load a TIFF image file. |
3c4f71cc VS |
989 | |
990 | ||
991 | ||
992 | ||
993 | ||
4cc4bfaf | 994 | wxBITMAP_TYPE_XPM |
3c4f71cc VS |
995 | |
996 | ||
997 | ||
998 | ||
4cc4bfaf | 999 | Load a XPM image file. |
3c4f71cc VS |
1000 | |
1001 | ||
1002 | ||
1003 | ||
1004 | ||
4cc4bfaf | 1005 | wxBITMAP_TYPE_ICO |
3c4f71cc VS |
1006 | |
1007 | ||
1008 | ||
1009 | ||
4cc4bfaf | 1010 | Load a Windows icon file (ICO). |
3c4f71cc VS |
1011 | |
1012 | ||
1013 | ||
1014 | ||
1015 | ||
4cc4bfaf | 1016 | wxBITMAP_TYPE_CUR |
3c4f71cc VS |
1017 | |
1018 | ||
1019 | ||
1020 | ||
4cc4bfaf | 1021 | Load a Windows cursor file (CUR). |
3c4f71cc VS |
1022 | |
1023 | ||
1024 | ||
1025 | ||
1026 | ||
4cc4bfaf | 1027 | wxBITMAP_TYPE_ANI |
3c4f71cc VS |
1028 | |
1029 | ||
1030 | ||
1031 | ||
4cc4bfaf | 1032 | Load a Windows animated cursor file (ANI). |
3c4f71cc VS |
1033 | |
1034 | ||
1035 | ||
1036 | ||
1037 | ||
4cc4bfaf | 1038 | wxBITMAP_TYPE_ANY |
3c4f71cc VS |
1039 | |
1040 | ||
1041 | ||
1042 | ||
4cc4bfaf FM |
1043 | Will try to autodetect the format. |
1044 | @param mimetype | |
1045 | MIME type string (for example 'image/jpeg') | |
7c913512 | 1046 | @param index |
4cc4bfaf FM |
1047 | Index of the image to load in the case that the image file contains |
1048 | multiple images. | |
1049 | This is only used by GIF, ICO and TIFF handlers. The default value (-1) | |
1050 | means | |
1051 | "choose the default image" and is interpreted as the first image (index=0) | |
1052 | by | |
1053 | the GIF and TIFF handler and as the largest and most colourful one by the | |
1054 | ICO handler. | |
3c4f71cc | 1055 | |
23324ae1 | 1056 | @returns @true if the operation succeeded, @false otherwise. If the |
4cc4bfaf FM |
1057 | optional index parameter is out of range, @false is |
1058 | returned and a call to wxLogError() takes place. | |
3c4f71cc | 1059 | |
23324ae1 | 1060 | @remarks Depending on how wxWidgets has been configured, not all formats |
4cc4bfaf | 1061 | may be available. |
3c4f71cc | 1062 | |
4cc4bfaf | 1063 | @see SaveFile() |
23324ae1 FM |
1064 | */ |
1065 | bool LoadFile(const wxString& name, | |
1066 | long type = wxBITMAP_TYPE_ANY, | |
1067 | int index = -1); | |
7c913512 FM |
1068 | bool LoadFile(const wxString& name, const wxString& mimetype, |
1069 | int index = -1); | |
1070 | bool LoadFile(wxInputStream& stream, long type, | |
1071 | int index = -1); | |
1072 | bool LoadFile(wxInputStream& stream, | |
1073 | const wxString& mimetype, | |
1074 | int index = -1); | |
23324ae1 FM |
1075 | //@} |
1076 | ||
1077 | /** | |
1078 | Returns a mirrored copy of the image. The parameter @e horizontally | |
1079 | indicates the orientation. | |
1080 | */ | |
328f5751 | 1081 | wxImage Mirror(bool horizontally = true) const; |
23324ae1 FM |
1082 | |
1083 | /** | |
4cc4bfaf | 1084 | Copy the data of the given @a image to the specified position in this image. |
23324ae1 FM |
1085 | */ |
1086 | void Paste(const wxImage& image, int x, int y); | |
1087 | ||
1088 | /** | |
1089 | Constructor for RGBValue, an object that contains values for red, green and | |
1090 | blue which | |
1091 | represent the value of a color. It is used by HSVtoRGB() | |
1092 | and RGBtoHSV(), which | |
1093 | converts between HSV color space and RGB color space. | |
1094 | */ | |
7c913512 FM |
1095 | RGBValue(unsigned char r = 0, unsigned char g = 0, |
1096 | unsigned char b = 0); | |
23324ae1 FM |
1097 | |
1098 | /** | |
1099 | Converts a color in RGB color space to HSV color space. | |
1100 | */ | |
1101 | #define wxImage::HSVValue RGBtoHSV(const RGBValue& rgb) /* implementation is private */ | |
1102 | ||
1103 | /** | |
1104 | Finds the handler with the given name, and removes it. The handler | |
1105 | is not deleted. | |
3c4f71cc | 1106 | |
7c913512 | 1107 | @param name |
4cc4bfaf | 1108 | The handler name. |
3c4f71cc | 1109 | |
23324ae1 | 1110 | @returns @true if the handler was found and removed, @false otherwise. |
3c4f71cc | 1111 | |
4cc4bfaf | 1112 | @see wxImageHandler |
23324ae1 FM |
1113 | */ |
1114 | static bool RemoveHandler(const wxString& name); | |
1115 | ||
1116 | /** | |
1117 | Replaces the colour specified by @e r1,g1,b1 by the colour @e r2,g2,b2. | |
1118 | */ | |
1119 | void Replace(unsigned char r1, unsigned char g1, | |
1120 | unsigned char b1, unsigned char r2, | |
1121 | unsigned char g2, unsigned char b2); | |
1122 | ||
1123 | /** | |
1124 | Changes the size of the image in-place by scaling it: after a call to this | |
1125 | function, | |
1126 | the image will have the given width and height. | |
4cc4bfaf | 1127 | For a description of the @a quality parameter, see the Scale() function. |
23324ae1 | 1128 | Returns the (modified) image itself. |
3c4f71cc | 1129 | |
4cc4bfaf | 1130 | @see Scale() |
23324ae1 FM |
1131 | */ |
1132 | wxImage Rescale(int width, int height, | |
1133 | int quality = wxIMAGE_QUALITY_NORMAL); | |
1134 | ||
1135 | /** | |
1136 | Changes the size of the image in-place without scaling it by adding either a | |
1137 | border | |
1138 | with the given colour or cropping as necessary. The image is pasted into a new | |
4cc4bfaf FM |
1139 | image with the given @a size and background colour at the position @e pos |
1140 | relative to the upper left of the new image. If @a red = green = blue = -1 | |
23324ae1 FM |
1141 | then use either the current mask colour if set or find, use, and set a |
1142 | suitable mask colour for any newly exposed areas. | |
23324ae1 | 1143 | Returns the (modified) image itself. |
3c4f71cc | 1144 | |
4cc4bfaf | 1145 | @see Size() |
23324ae1 FM |
1146 | */ |
1147 | wxImage Resize(const wxSize& size, const wxPoint pos, | |
1148 | int red = -1, int green = -1, | |
1149 | int blue = -1); | |
1150 | ||
1151 | /** | |
4cc4bfaf FM |
1152 | Rotates the image about the given point, by @a angle radians. Passing @true |
1153 | to @a interpolating results in better image quality, but is slower. If the | |
23324ae1 FM |
1154 | image has a mask, then the mask colour is used for the uncovered pixels in the |
1155 | rotated image background. Else, black (rgb 0, 0, 0) will be used. | |
23324ae1 FM |
1156 | Returns the rotated image, leaving this image intact. |
1157 | */ | |
1158 | wxImage Rotate(double angle, const wxPoint& rotationCentre, | |
4cc4bfaf FM |
1159 | bool interpolating = true, |
1160 | wxPoint* offsetAfterRotation = NULL); | |
23324ae1 FM |
1161 | |
1162 | /** | |
1163 | Returns a copy of the image rotated 90 degrees in the direction | |
1164 | indicated by @e clockwise. | |
1165 | */ | |
328f5751 | 1166 | wxImage Rotate90(bool clockwise = true) const; |
23324ae1 FM |
1167 | |
1168 | /** | |
1169 | Rotates the hue of each pixel in the image by @e angle, which is a double in | |
1170 | the range of -1.0 to +1.0, where -1.0 corresponds to -360 degrees and +1.0 | |
1171 | corresponds | |
1172 | to +360 degrees. | |
1173 | */ | |
1174 | void RotateHue(double angle); | |
1175 | ||
1176 | //@{ | |
1177 | /** | |
1178 | Saves an image in the given stream. | |
3c4f71cc | 1179 | |
7c913512 | 1180 | @param name |
4cc4bfaf | 1181 | Name of the file to save the image to. |
7c913512 | 1182 | @param stream |
4cc4bfaf | 1183 | Opened output stream to save the image to. |
7c913512 | 1184 | @param type |
4cc4bfaf | 1185 | Currently these types can be used: |
3c4f71cc VS |
1186 | |
1187 | ||
1188 | ||
1189 | ||
1190 | ||
1191 | ||
4cc4bfaf | 1192 | wxBITMAP_TYPE_BMP |
3c4f71cc VS |
1193 | |
1194 | ||
1195 | ||
1196 | ||
4cc4bfaf | 1197 | Save a BMP image file. |
3c4f71cc VS |
1198 | |
1199 | ||
1200 | ||
1201 | ||
1202 | ||
4cc4bfaf | 1203 | wxBITMAP_TYPE_JPEG |
3c4f71cc VS |
1204 | |
1205 | ||
1206 | ||
1207 | ||
4cc4bfaf | 1208 | Save a JPEG image file. |
3c4f71cc VS |
1209 | |
1210 | ||
1211 | ||
1212 | ||
1213 | ||
4cc4bfaf | 1214 | wxBITMAP_TYPE_PNG |
3c4f71cc VS |
1215 | |
1216 | ||
1217 | ||
1218 | ||
4cc4bfaf | 1219 | Save a PNG image file. |
3c4f71cc VS |
1220 | |
1221 | ||
1222 | ||
1223 | ||
1224 | ||
4cc4bfaf | 1225 | wxBITMAP_TYPE_PCX |
3c4f71cc VS |
1226 | |
1227 | ||
1228 | ||
1229 | ||
4cc4bfaf FM |
1230 | Save a PCX image file (tries to save as 8-bit if possible, falls back to |
1231 | 24-bit otherwise). | |
3c4f71cc VS |
1232 | |
1233 | ||
1234 | ||
1235 | ||
1236 | ||
4cc4bfaf | 1237 | wxBITMAP_TYPE_PNM |
3c4f71cc VS |
1238 | |
1239 | ||
1240 | ||
1241 | ||
4cc4bfaf | 1242 | Save a PNM image file (as raw RGB always). |
3c4f71cc VS |
1243 | |
1244 | ||
1245 | ||
1246 | ||
1247 | ||
4cc4bfaf | 1248 | wxBITMAP_TYPE_TIFF |
3c4f71cc VS |
1249 | |
1250 | ||
1251 | ||
1252 | ||
4cc4bfaf | 1253 | Save a TIFF image file. |
3c4f71cc VS |
1254 | |
1255 | ||
1256 | ||
1257 | ||
1258 | ||
4cc4bfaf | 1259 | wxBITMAP_TYPE_XPM |
3c4f71cc VS |
1260 | |
1261 | ||
1262 | ||
1263 | ||
4cc4bfaf | 1264 | Save a XPM image file. |
3c4f71cc VS |
1265 | |
1266 | ||
1267 | ||
1268 | ||
1269 | ||
4cc4bfaf | 1270 | wxBITMAP_TYPE_ICO |
3c4f71cc VS |
1271 | |
1272 | ||
1273 | ||
1274 | ||
4cc4bfaf FM |
1275 | Save a Windows icon file (ICO) (the size may be up to 255 wide by 127 high. |
1276 | A single image is saved in 8 colors at the size supplied). | |
3c4f71cc VS |
1277 | |
1278 | ||
1279 | ||
1280 | ||
1281 | ||
4cc4bfaf | 1282 | wxBITMAP_TYPE_CUR |
3c4f71cc VS |
1283 | |
1284 | ||
1285 | ||
1286 | ||
4cc4bfaf | 1287 | Save a Windows cursor file (CUR). |
7c913512 | 1288 | @param mimetype |
4cc4bfaf | 1289 | MIME type. |
3c4f71cc | 1290 | |
23324ae1 | 1291 | @returns @true if the operation succeeded, @false otherwise. |
3c4f71cc | 1292 | |
23324ae1 | 1293 | @remarks Depending on how wxWidgets has been configured, not all formats |
4cc4bfaf | 1294 | may be available. |
3c4f71cc | 1295 | |
4cc4bfaf | 1296 | @see LoadFile() |
23324ae1 | 1297 | */ |
328f5751 FM |
1298 | bool SaveFile(const wxString& name, int type) const; |
1299 | const bool SaveFile(const wxString& name, | |
1300 | const wxString& mimetype) const; | |
1301 | const bool SaveFile(const wxString& name) const; | |
1302 | const bool SaveFile(wxOutputStream& stream, int type) const; | |
1303 | const bool SaveFile(wxOutputStream& stream, | |
1304 | const wxString& mimetype) const; | |
23324ae1 FM |
1305 | //@} |
1306 | ||
1307 | /** | |
1308 | Returns a scaled version of the image. This is also useful for | |
1309 | scaling bitmaps in general as the only other way to scale bitmaps | |
1310 | is to blit a wxMemoryDC into another wxMemoryDC. | |
23324ae1 FM |
1311 | It should be noted that although using wxIMAGE_QUALITY_HIGH produces much nicer |
1312 | looking results it is a slower method. Downsampling will use the box averaging | |
1313 | method | |
1314 | which seems to operate very fast. If you are upsampling larger images using | |
1315 | this method you will most likely notice that it is a bit slower and in extreme | |
1316 | cases | |
1317 | it will be quite substantially slower as the bicubic algorithm has to process a | |
1318 | lot of | |
1319 | data. | |
23324ae1 FM |
1320 | It should also be noted that the high quality scaling may not work as expected |
1321 | when using a single mask colour for transparency, as the scaling will blur the | |
1322 | image and will therefore remove the mask partially. Using the alpha channel | |
1323 | will work. | |
23324ae1 | 1324 | Example: |
3c4f71cc | 1325 | |
7c913512 | 1326 | @param quality |
4cc4bfaf | 1327 | Determines what method to use for resampling the image. Can be one of the |
23324ae1 | 1328 | following: |
3c4f71cc VS |
1329 | |
1330 | ||
1331 | ||
1332 | ||
1333 | ||
1334 | ||
4cc4bfaf | 1335 | wxIMAGE_QUALITY_NORMAL |
3c4f71cc VS |
1336 | |
1337 | ||
1338 | ||
1339 | ||
4cc4bfaf | 1340 | Uses the normal default scaling method of pixel replication |
3c4f71cc VS |
1341 | |
1342 | ||
1343 | ||
1344 | ||
1345 | ||
4cc4bfaf | 1346 | wxIMAGE_QUALITY_HIGH |
3c4f71cc VS |
1347 | |
1348 | ||
1349 | ||
1350 | ||
4cc4bfaf | 1351 | Uses bicubic and box averaging resampling methods for upsampling and |
23324ae1 | 1352 | downsampling respectively |
3c4f71cc | 1353 | |
4cc4bfaf | 1354 | @see Rescale() |
23324ae1 FM |
1355 | */ |
1356 | wxImage Scale(int width, int height, | |
328f5751 | 1357 | int quality = wxIMAGE_QUALITY_NORMAL) const; |
23324ae1 FM |
1358 | |
1359 | //@{ | |
1360 | /** | |
1361 | Sets the alpha value for the given pixel. This function should only be called | |
1362 | if the image has alpha channel data, use HasAlpha() to | |
1363 | check for this. | |
1364 | */ | |
4cc4bfaf FM |
1365 | void SetAlpha(unsigned char* alpha = NULL, |
1366 | bool static_data = false); | |
7c913512 | 1367 | void SetAlpha(int x, int y, unsigned char alpha); |
23324ae1 FM |
1368 | //@} |
1369 | ||
1370 | /** | |
1371 | Sets the image data without performing checks. The data given must have | |
1372 | the size (width*height*3) or results will be unexpected. Don't use this | |
1373 | method if you aren't sure you know what you are doing. | |
23324ae1 FM |
1374 | The data must have been allocated with @c malloc(), @b NOT with |
1375 | @c operator new. | |
23324ae1 FM |
1376 | After this call the pointer to the data is owned by the wxImage object, |
1377 | that will be responsible for deleting it. | |
1378 | Do not pass to this function a pointer obtained through | |
1379 | GetData(). | |
1380 | */ | |
1381 | void SetData(unsigned char* data); | |
1382 | ||
1383 | /** | |
1384 | Specifies whether there is a mask or not. The area of the mask is determined by | |
1385 | the current mask colour. | |
1386 | */ | |
4cc4bfaf | 1387 | void SetMask(bool hasMask = true); |
23324ae1 FM |
1388 | |
1389 | /** | |
1390 | Sets the mask colour for this image (and tells the image to use the mask). | |
1391 | */ | |
1392 | void SetMaskColour(unsigned char red, unsigned char green, | |
1393 | unsigned char blue); | |
1394 | ||
1395 | /** | |
7c913512 | 1396 | @param mask |
4cc4bfaf | 1397 | The mask image to extract mask shape from. Must have same dimensions as the |
23324ae1 | 1398 | image. |
7c913512 | 1399 | @param mr,mg,mb |
4cc4bfaf | 1400 | RGB value of pixels in mask that will be used to create the mask. |
3c4f71cc | 1401 | |
23324ae1 | 1402 | @returns Returns @false if mask does not have same dimensions as the image |
4cc4bfaf FM |
1403 | or if there is no unused colour left. Returns @true if |
1404 | the mask was successfully applied. | |
23324ae1 FM |
1405 | */ |
1406 | bool SetMaskFromImage(const wxImage& mask, unsigned char mr, | |
1407 | unsigned char mg, | |
1408 | unsigned char mb); | |
1409 | ||
1410 | //@{ | |
1411 | /** | |
1412 | Sets a user-defined option. The function is case-insensitive to @e name. | |
23324ae1 FM |
1413 | For example, when saving as a JPEG file, the option @b quality is |
1414 | used, which is a number between 0 and 100 (0 is terrible, 100 is very good). | |
3c4f71cc | 1415 | |
4cc4bfaf | 1416 | @see GetOption(), GetOptionInt(), HasOption() |
23324ae1 FM |
1417 | */ |
1418 | void SetOption(const wxString& name, const wxString& value); | |
7c913512 | 1419 | void SetOption(const wxString& name, int value); |
23324ae1 FM |
1420 | //@} |
1421 | ||
1422 | /** | |
1423 | Associates a palette with the image. The palette may be used when converting | |
1424 | wxImage to wxBitmap (MSW only at present) or in file save operations (none as | |
1425 | yet). | |
1426 | */ | |
1427 | void SetPalette(const wxPalette& palette); | |
1428 | ||
1429 | /** | |
1430 | Sets the colour of the pixels within the given rectangle. This routine performs | |
1431 | bounds-checks for the coordinate so it can be considered a safe way to | |
1432 | manipulate the | |
1433 | data. | |
1434 | */ | |
4cc4bfaf FM |
1435 | void SetRGB(wxRect& rect, unsigned char red, |
1436 | unsigned char green, | |
1437 | unsigned char blue); | |
23324ae1 FM |
1438 | |
1439 | /** | |
1440 | Returns a resized version of this image without scaling it by adding either a | |
1441 | border | |
1442 | with the given colour or cropping as necessary. The image is pasted into a new | |
4cc4bfaf FM |
1443 | image with the given @a size and background colour at the position @e pos |
1444 | relative to the upper left of the new image. If @a red = green = blue = -1 | |
23324ae1 FM |
1445 | then the areas of the larger image not covered by this image are made |
1446 | transparent by filling them with the image mask colour (which will be allocated | |
1447 | automatically if it isn't currently set). Otherwise, the areas will be filled | |
1448 | with the colour with the specified RGB components. | |
3c4f71cc | 1449 | |
4cc4bfaf | 1450 | @see Resize() |
23324ae1 FM |
1451 | */ |
1452 | wxImage Size(const wxSize& size, const wxPoint pos, int red = -1, | |
328f5751 | 1453 | int green = -1, int blue = -1) const; |
23324ae1 FM |
1454 | |
1455 | /** | |
1456 | Assignment operator, using @ref overview_trefcount "reference counting". | |
3c4f71cc | 1457 | |
7c913512 | 1458 | @param image |
4cc4bfaf | 1459 | Image to assign. |
3c4f71cc | 1460 | |
23324ae1 FM |
1461 | @returns Returns 'this' object. |
1462 | */ | |
1463 | wxImage operator =(const wxImage& image); | |
1464 | }; | |
1465 | ||
65874118 FM |
1466 | /** |
1467 | An empty wxImage. | |
1468 | */ | |
1469 | wxImage wxNullImage; | |
23324ae1 | 1470 | |
e54c96f1 | 1471 | |
23324ae1 FM |
1472 | // ============================================================================ |
1473 | // Global functions/macros | |
1474 | // ============================================================================ | |
1475 | ||
8cd06fb5 BP |
1476 | /** @ingroup group_funcmacro_appinitterm */ |
1477 | //@{ | |
1478 | ||
23324ae1 FM |
1479 | /** |
1480 | Initializes all available image handlers. For a list of available handlers, | |
1481 | see wxImage. | |
7c913512 | 1482 | |
4cc4bfaf | 1483 | @see wxImage, wxImageHandler |
027c1c27 BP |
1484 | |
1485 | @header{wx/image.h} | |
23324ae1 FM |
1486 | */ |
1487 | void wxInitAllImageHandlers(); | |
1488 | ||
8cd06fb5 BP |
1489 | //@} |
1490 |