]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_image.i
Tests for UTF-8 and PUA characters and octal escapes
[wxWidgets.git] / wxPython / src / _image.i
CommitLineData
cf694132 1/////////////////////////////////////////////////////////////////////////////
d14a1e28
RD
2// Name: _image.i
3// Purpose: SWIG definitions for wxImage and such
cf694132
RD
4//
5// Author: Robin Dunn
6//
d14a1e28 7// Created: 25-Sept-2000
cf694132 8// RCS-ID: $Id$
d14a1e28 9// Copyright: (c) 2003 by Total Control Software
cf694132
RD
10// Licence: wxWindows license
11/////////////////////////////////////////////////////////////////////////////
12
d14a1e28 13// Not a %module
cf694132 14
d14a1e28
RD
15
16//---------------------------------------------------------------------------
cf694132
RD
17
18%{
d14a1e28 19#include "wx/wxPython/pyistream.h"
cf694132
RD
20%}
21
9cbf6f6e 22//---------------------------------------------------------------------------
d14a1e28 23%newgroup
9cbf6f6e 24
cf694132 25
9416aa89 26class wxImageHandler : public wxObject {
cf694132 27public:
1dec68aa 28 // wxImageHandler(); Abstract Base Class
cf694132
RD
29 wxString GetName();
30 wxString GetExtension();
31 long GetType();
32 wxString GetMimeType();
33
34 //bool LoadFile(wxImage* image, wxInputStream& stream);
35 //bool SaveFile(wxImage* image, wxOutputStream& stream);
b5a5d647
RD
36 //virtual int GetImageCount( wxInputStream& stream );
37 //bool CanRead( wxInputStream& stream );
38
39 bool CanRead( const wxString& name );
cf694132
RD
40
41 void SetName(const wxString& name);
42 void SetExtension(const wxString& extension);
43 void SetType(long type);
44 void SetMimeType(const wxString& mimetype);
45};
46
cf694132 47
d14a1e28 48//---------------------------------------------------------------------------
cf694132 49
d14a1e28
RD
50class wxImageHistogram /* : public wxImageHistogramBase */
51{
06c0fba4 52public:
d14a1e28 53 wxImageHistogram();
cf694132 54
d07d2bc9 55 DocStr(MakeKey, "Get the key in the histogram for the given RGB values", "");
d14a1e28
RD
56 static unsigned long MakeKey(unsigned char r,
57 unsigned char g,
58 unsigned char b);
cf694132 59
dd9f7fea
RD
60 DocDeclAStr(
61 bool, FindFirstUnusedColour(unsigned char *OUTPUT,
62 unsigned char *OUTPUT,
63 unsigned char *OUTPUT,
64 unsigned char startR = 1,
65 unsigned char startG = 0,
66 unsigned char startB = 0 ) const,
67 "FindFirstUnusedColour(int startR=1, int startG=0, int startB=0) -> (success, r, g, b)",
d07d2bc9
RD
68 "Find first colour that is not used in the image and has higher RGB
69values than startR, startG, startB. Returns a tuple consisting of a
70success flag and rgb values.", "");
41c48dbb
RD
71
72 %extend {
73 DocStr(GetCount,
74 "Returns the pixel count for the given key. Use `MakeKey` to create a
75key value from a RGB tripple.", "");
76 unsigned long GetCount(unsigned long key) {
77 wxImageHistogramEntry e = (*self)[key];
78 return e.value;
79 }
80
81 DocStr(GetCountRGB,
82 "Returns the pixel count for the given RGB values.", "");
83 unsigned long GetCountRGB(unsigned char r,
84 unsigned char g,
85 unsigned char b) {
86 unsigned long key = wxImageHistogram::MakeKey(r, g, b);
87 wxImageHistogramEntry e = (*self)[key];
88 return e.value;
89 }
90
91 DocStr(GetCountColour,
92 "Returns the pixel count for the given `wx.Colour` value.", "");
93 unsigned long GetCountColour(const wxColour& colour) {
94 unsigned long key = wxImageHistogram::MakeKey(colour.Red(),
95 colour.Green(),
96 colour.Blue());
97 wxImageHistogramEntry e = (*self)[key];
98 return e.value;
99 }
100 }
101
9b3d3bc4
RD
102};
103
104
cf694132
RD
105//---------------------------------------------------------------------------
106
d14a1e28 107
9416aa89 108class wxImage : public wxObject {
cf694132 109public:
1b8c7ba6
RD
110 DocCtorStr(
111 wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ),
112 "", "");
113
cf694132
RD
114 ~wxImage();
115
d14a1e28 116 // Alternate constructors
1b8c7ba6
RD
117 DocCtorStrName(
118 wxImage(const wxString& name, const wxString& mimetype, int index = -1),
119 "", "",
120 ImageFromMime);
121
122 DocCtorStrName(
123 wxImage(wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1),
124 "", "",
125 ImageFromStream);
126
127 DocCtorStrName(
128 wxImage(wxInputStream& stream, const wxString& mimetype, int index = -1 ),
129 "", "",
130 ImageFromStreamMime);
131
d14a1e28 132 %extend {
1b8c7ba6
RD
133 %rename(EmptyImage) wxImage(int width=0, int height=0, bool clear = true);
134 wxImage(int width=0, int height=0, bool clear = true)
135 {
d14a1e28
RD
136 if (width > 0 && height > 0)
137 return new wxImage(width, height, clear);
138 else
139 return new wxImage;
be43ef04 140 }
ab1f7d2a
RD
141
142 MustHaveApp(wxImage(const wxBitmap &bitmap));
1b8c7ba6
RD
143 %rename(ImageFromBitmap) wxImage(const wxBitmap &bitmap);
144 wxImage(const wxBitmap &bitmap)
145 {
d14a1e28
RD
146 return new wxImage(bitmap.ConvertToImage());
147 }
be43ef04 148
1b8c7ba6
RD
149 %rename(ImageFromData) wxImage(int width, int height, unsigned char* data);
150 wxImage(int width, int height, unsigned char* data)
151 {
d14a1e28
RD
152 // Copy the source data so the wxImage can clean it up later
153 unsigned char* copy = (unsigned char*)malloc(width*height*3);
154 if (copy == NULL) {
155 PyErr_NoMemory();
156 return NULL;
157 }
158 memcpy(copy, data, width*height*3);
a72f4631 159 return new wxImage(width, height, copy, false);
d14a1e28 160 }
1b8c7ba6
RD
161
162
163 %rename(ImageFromDataWithAlpha) wxImage(int width, int height, unsigned char* data, unsigned char* alpha);
164 wxImage(int width, int height, unsigned char* data, unsigned char* alpha)
165 {
c6d42899
RD
166 // Copy the source data so the wxImage can clean it up later
167 unsigned char* dcopy = (unsigned char*)malloc(width*height*3);
168 if (dcopy == NULL) {
169 PyErr_NoMemory();
170 return NULL;
171 }
172 memcpy(dcopy, data, width*height*3);
173 unsigned char* acopy = (unsigned char*)malloc(width*height);
174 if (acopy == NULL) {
175 PyErr_NoMemory();
176 return NULL;
177 }
178 memcpy(acopy, alpha, width*height);
179
180 return new wxImage(width, height, dcopy, acopy, false);
181 }
d14a1e28 182 }
be43ef04 183
9df51bd0
RD
184 // TODO: wxImage( char** xpmData );
185
186
cf694132
RD
187 void Create( int width, int height );
188 void Destroy();
6c0168c9 189
cf694132 190 wxImage Scale( int width, int height );
9cbf6f6e 191 wxImage ShrinkBy( int xFactor , int yFactor ) const ;
f6bcfd97 192 wxImage& Rescale(int width, int height);
cf694132 193
f5bac082
RD
194 // resizes the image in place
195 wxImage& Resize( const wxSize& size, const wxPoint& pos,
196 int r = -1, int g = -1, int b = -1 );
197
cf694132 198 void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
f5bac082
RD
199
200 %Rename(SetRGBRect,
201 void, SetRGB( const wxRect& rect,
202 unsigned char r, unsigned char g, unsigned char b ));
203
cf694132
RD
204 unsigned char GetRed( int x, int y );
205 unsigned char GetGreen( int x, int y );
206 unsigned char GetBlue( int x, int y );
207
9cbf6f6e
RD
208 void SetAlpha(int x, int y, unsigned char alpha);
209 unsigned char GetAlpha(int x, int y);
210 bool HasAlpha();
211
655e17cf
RD
212 DocDeclStr(
213 void , InitAlpha(),
214 "Initializes the image alpha channel data. It is an error to call it if
215the image already has alpha data. If it doesn't, alpha data will be by
216default initialized to all pixels being fully opaque. But if the image
217has a a mask colour, all mask pixels will be completely transparent.", "");
218
219
9cbf6f6e 220 // find first colour that is not used in the image and has higher
68bc8549 221 // RGB values than <startR,startG,startB>
dd9f7fea
RD
222 DocDeclAStr(
223 bool, FindFirstUnusedColour( byte *OUTPUT, byte *OUTPUT, byte *OUTPUT,
224 byte startR = 0, byte startG = 0, byte startB = 0 ) const,
225 "FindFirstUnusedColour(int startR=1, int startG=0, int startB=0) -> (success, r, g, b)",
d07d2bc9
RD
226 "Find first colour that is not used in the image and has higher RGB
227values than startR, startG, startB. Returns a tuple consisting of a
228success flag and rgb values.", "");
dd9f7fea 229
125c972b
RD
230
231 DocDeclStr(
232 bool , ConvertAlphaToMask(byte threshold = 128),
233 "If the image has alpha channel, this method converts it to mask. All pixels
234with alpha value less than ``threshold`` are replaced with mask colour and the
235alpha channel is removed. Mask colour is chosen automatically using
236`FindFirstUnusedColour`.
237
238If the image image doesn't have alpha channel, ConvertAlphaToMask does
239nothing.", "");
240
241
6f7ecb3b
RD
242 DocDeclStr(
243 bool , ConvertColourToAlpha( unsigned char r, unsigned char g, unsigned char b ),
244 "This method converts an image where the original alpha information is
245only available as a shades of a colour (actually shades of grey)
246typically when you draw anti-aliased text into a bitmap. The DC
247drawing routines draw grey values on the black background although
248they actually mean to draw white with differnt alpha values. This
249method reverses it, assuming a black (!) background and white text.
250The method will then fill up the whole image with the colour given.", "");
251
252
125c972b 253
68bc8549
RD
254 // Set image's mask to the area of 'mask' that has <mr,mg,mb> colour
255 bool SetMaskFromImage(const wxImage & mask,
256 byte mr, byte mg, byte mb);
257
db0ff83e
RD
258// void DoFloodFill (wxCoord x, wxCoord y,
259// const wxBrush & fillBrush,
260// const wxColour& testColour,
261// int style = wxFLOOD_SURFACE,
262// int LogicalFunction = wxCOPY /* currently unused */ ) ;
68bc8549 263
96bfd053 264 static bool CanRead( const wxString& name );
b5a5d647
RD
265 static int GetImageCount( const wxString& name, long type = wxBITMAP_TYPE_ANY );
266
267 bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 );
1b8c7ba6 268 %Rename(LoadMimeFile, bool, LoadFile( const wxString& name, const wxString& mimetype, int index = -1 ));
cf694132
RD
269
270 bool SaveFile( const wxString& name, int type );
1b8c7ba6 271 %Rename(SaveMimeFile, bool, SaveFile( const wxString& name, const wxString& mimetype ));
cf694132 272
1b8c7ba6
RD
273 %Rename(CanReadStream, static bool, CanRead( wxInputStream& stream ));
274 %Rename(LoadStream, bool, LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1 ));
275 %Rename(LoadMimeStream, bool, LoadFile( wxInputStream& stream, const wxString& mimetype, int index = -1 ));
f74ff5ef 276
cf694132
RD
277 bool Ok();
278 int GetWidth();
279 int GetHeight();
280
ba938c3d
RD
281 %extend {
282 wxSize GetSize() {
283 wxSize size(self->GetWidth(), self->GetHeight());
284 return size;
285 }
286 }
287
9d8bd15f 288 wxImage GetSubImage(const wxRect& rect);
f5bac082
RD
289
290 // Paste the image or part of this image into an image of the given size at the pos
291 // any newly exposed areas will be filled with the rgb colour
292 // by default if r = g = b = -1 then fill with this image's mask colour or find and
293 // set a suitable mask colour
294 wxImage Size( const wxSize& size, const wxPoint& pos,
295 int r = -1, int g = -1, int b = -1 ) const;
296
f6bcfd97
BP
297 wxImage Copy();
298 void Paste( const wxImage &image, int x, int y );
9d8bd15f 299
1dc2f865
RD
300 //unsigned char *GetData();
301 //void SetData( unsigned char *data );
302
d14a1e28 303 %extend {
9cbf6f6e 304 PyObject* GetData() {
d55d6b3f
RD
305 unsigned char* data = self->GetData();
306 int len = self->GetWidth() * self->GetHeight() * 3;
d14a1e28
RD
307 PyObject* rv;
308 wxPyBLOCK_THREADS( rv = PyString_FromStringAndSize((char*)data, len));
309 return rv;
d55d6b3f 310 }
9cbf6f6e
RD
311 void SetData(PyObject* data) {
312 unsigned char* dataPtr;
d55d6b3f 313
9cbf6f6e 314 if (! PyString_Check(data)) {
debff7aa
RD
315 wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError,
316 "Expected string object"));
9cbf6f6e
RD
317 return /* NULL */ ;
318 }
319
320 size_t len = self->GetWidth() * self->GetHeight() * 3;
321 dataPtr = (unsigned char*) malloc(len);
d14a1e28 322 wxPyBLOCK_THREADS( memcpy(dataPtr, PyString_AsString(data), len) );
9cbf6f6e
RD
323 self->SetData(dataPtr);
324 // wxImage takes ownership of dataPtr...
325 }
326
327
328
329 PyObject* GetDataBuffer() {
1dc2f865
RD
330 unsigned char* data = self->GetData();
331 int len = self->GetWidth() * self->GetHeight() * 3;
d14a1e28
RD
332 PyObject* rv;
333 wxPyBLOCK_THREADS( rv = PyBuffer_FromReadWriteMemory(data, len) );
334 return rv;
1dc2f865 335 }
1e4a197e
RD
336 void SetDataBuffer(PyObject* data) {
337 unsigned char* buffer;
338 int size;
339
6e6b3557 340 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
341 if (!PyArg_Parse(data, "t#", &buffer, &size))
342 goto done;
1e4a197e
RD
343
344 if (size != self->GetWidth() * self->GetHeight() * 3) {
345 PyErr_SetString(PyExc_TypeError, "Incorrect buffer size");
d14a1e28 346 goto done;
1e4a197e 347 }
1e4a197e 348 self->SetData(buffer);
d14a1e28 349 done:
da32eb53 350 wxPyEndBlockThreads(blocked);
1e4a197e
RD
351 }
352
9cbf6f6e
RD
353
354
355 PyObject* GetAlphaData() {
356 unsigned char* data = self->GetAlpha();
357 if (! data) {
358 RETURN_NONE();
359 } else {
360 int len = self->GetWidth() * self->GetHeight();
d14a1e28
RD
361 PyObject* rv;
362 wxPyBLOCK_THREADS( rv = PyString_FromStringAndSize((char*)data, len) );
363 return rv;
9cbf6f6e
RD
364 }
365 }
366 void SetAlphaData(PyObject* data) {
1dc2f865
RD
367 unsigned char* dataPtr;
368
369 if (! PyString_Check(data)) {
370 PyErr_SetString(PyExc_TypeError, "Expected string object");
371 return /* NULL */ ;
372 }
9d8bd15f 373
9cbf6f6e 374 size_t len = self->GetWidth() * self->GetHeight();
185d7c3e 375 dataPtr = (unsigned char*) malloc(len);
d14a1e28 376 wxPyBLOCK_THREADS( memcpy(dataPtr, PyString_AsString(data), len) );
9cbf6f6e 377 self->SetAlpha(dataPtr);
3b5ccda1 378 // wxImage takes ownership of dataPtr...
1dc2f865 379 }
9cbf6f6e
RD
380
381
382
383 PyObject* GetAlphaBuffer() {
384 unsigned char* data = self->GetAlpha();
385 int len = self->GetWidth() * self->GetHeight();
d14a1e28
RD
386 PyObject* rv;
387 wxPyBLOCK_THREADS( rv = PyBuffer_FromReadWriteMemory(data, len) );
388 return rv;
9cbf6f6e
RD
389 }
390 void SetAlphaBuffer(PyObject* data) {
391 unsigned char* buffer;
392 int size;
393
6e6b3557 394 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d14a1e28
RD
395 if (!PyArg_Parse(data, "t#", &buffer, &size))
396 goto done;
9cbf6f6e
RD
397
398 if (size != self->GetWidth() * self->GetHeight()) {
399 PyErr_SetString(PyExc_TypeError, "Incorrect buffer size");
d14a1e28 400 goto done;
9cbf6f6e
RD
401 }
402 self->SetAlpha(buffer);
d14a1e28 403 done:
da32eb53 404 wxPyEndBlockThreads(blocked);
9cbf6f6e 405 }
1dc2f865 406 }
cf694132
RD
407
408 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
f5bac082
RD
409
410 DocDeclAStr(
411 /*bool*/ void , GetOrFindMaskColour( unsigned char *OUTPUT,
412 unsigned char *OUTPUT,
413 unsigned char *OUTPUT ) const,
414 "GetOrFindMaskColour() -> (r,g,b)",
415 "Get the current mask colour or find a suitable colour.", "");
416
417
cf694132
RD
418 unsigned char GetMaskRed();
419 unsigned char GetMaskGreen();
420 unsigned char GetMaskBlue();
a72f4631 421 void SetMask( bool mask = true );
cf694132
RD
422 bool HasMask();
423
f6bcfd97 424 wxImage Rotate(double angle, const wxPoint & centre_of_rotation,
a72f4631
RD
425 bool interpolating = true, wxPoint * offset_after_rotation = NULL) const ;
426 wxImage Rotate90( bool clockwise = true ) ;
427 wxImage Mirror( bool horizontally = true ) ;
f6bcfd97
BP
428
429 void Replace( unsigned char r1, unsigned char g1, unsigned char b1,
430 unsigned char r2, unsigned char g2, unsigned char b2 );
431
6c0168c9
RD
432 // convert to monochrome image (<r,g,b> will be replaced by white, everything else by black)
433 wxImage ConvertToMono( unsigned char r, unsigned char g, unsigned char b ) const;
434
435 void SetOption(const wxString& name, const wxString& value);
1b8c7ba6 436 %Rename(SetOptionInt, void, SetOption(const wxString& name, int value));
6c0168c9
RD
437 wxString GetOption(const wxString& name) const;
438 int GetOptionInt(const wxString& name) const;
439 bool HasOption(const wxString& name) const;
440
f6bcfd97 441 unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
9cbf6f6e 442 unsigned long ComputeHistogram( wxImageHistogram& h );
f6bcfd97 443
96bfd053
RD
444 static void AddHandler( wxImageHandler *handler );
445 static void InsertHandler( wxImageHandler *handler );
446 static bool RemoveHandler( const wxString& name );
3ef86e32 447 static wxString GetImageExtWildcard();
b96c7a38
RD
448
449
ab1f7d2a
RD
450MustHaveApp(ConvertToBitmap);
451MustHaveApp(ConvertToMonoBitmap);
be43ef04 452
d14a1e28 453 %extend {
12523ae4
RD
454 wxBitmap ConvertToBitmap(int depth=-1) {
455 wxBitmap bitmap(*self, depth);
b96c7a38
RD
456 return bitmap;
457 }
458
459 wxBitmap ConvertToMonoBitmap( unsigned char red,
460 unsigned char green,
461 unsigned char blue ) {
462 wxImage mono = self->ConvertToMono( red, green, blue );
463 wxBitmap bitmap( mono, 1 );
464 return bitmap;
465 }
466 }
1fded56b 467
d14a1e28 468 %pythoncode { def __nonzero__(self): return self.Ok() }
cf694132
RD
469};
470
926bb76c 471
f74ff5ef 472
a3150741
RD
473///void wxInitAllImageHandlers();
474
475%pythoncode {
476 def InitAllImageHandlers():
477 """
478 The former functionality of InitAllImageHanders is now done internal to
479 the _core_ extension module and so this function has become a simple NOP.
480 """
481 pass
482}
483
cf694132 484
f74ff5ef 485
d14a1e28
RD
486// See also wxPy_ReinitStockObjects in helpers.cpp
487%immutable;
488const wxImage wxNullImage;
489%mutable;
cf694132 490
d14a1e28 491//---------------------------------------------------------------------------
f74ff5ef 492
655e17cf 493MAKE_CONST_WXSTRING(IMAGE_OPTION_FILENAME);
d14a1e28
RD
494MAKE_CONST_WXSTRING(IMAGE_OPTION_BMP_FORMAT);
495MAKE_CONST_WXSTRING(IMAGE_OPTION_CUR_HOTSPOT_X);
496MAKE_CONST_WXSTRING(IMAGE_OPTION_CUR_HOTSPOT_Y);
497MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTION);
655e17cf
RD
498MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTIONX);
499MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTIONY);
be43ef04 500MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTIONUNIT);
97185340 501MAKE_CONST_WXSTRING(IMAGE_OPTION_QUALITY);
f74ff5ef 502
d14a1e28
RD
503enum
504{
505 wxIMAGE_RESOLUTION_INCHES = 1,
506 wxIMAGE_RESOLUTION_CM = 2
507};
f74ff5ef
RD
508
509
655e17cf
RD
510MAKE_CONST_WXSTRING(IMAGE_OPTION_BITSPERSAMPLE);
511MAKE_CONST_WXSTRING(IMAGE_OPTION_SAMPLESPERPIXEL);
512MAKE_CONST_WXSTRING(IMAGE_OPTION_COMPRESSION);
513MAKE_CONST_WXSTRING(IMAGE_OPTION_IMAGEDESCRIPTOR);
514
9df51bd0
RD
515MAKE_CONST_WXSTRING(IMAGE_OPTION_PNG_FORMAT);
516MAKE_CONST_WXSTRING(IMAGE_OPTION_PNG_BITDEPTH);
517
518enum
519{
520 wxPNG_TYPE_COLOUR = 0,
521 wxPNG_TYPE_GREY = 2,
522 wxPNG_TYPE_GREY_RED = 3
523};
524
d14a1e28
RD
525enum
526{
527 wxBMP_24BPP = 24, // default, do not need to set
528 //wxBMP_16BPP = 16, // wxQuantize can only do 236 colors?
529 wxBMP_8BPP = 8, // 8bpp, quantized colors
530 wxBMP_8BPP_GREY = 9, // 8bpp, rgb averaged to greys
531 wxBMP_8BPP_GRAY = wxBMP_8BPP_GREY,
532 wxBMP_8BPP_RED = 10, // 8bpp, red used as greyscale
533 wxBMP_8BPP_PALETTE = 11, // 8bpp, use the wxImage's palette
534 wxBMP_4BPP = 4, // 4bpp, quantized colors
535 wxBMP_1BPP = 1, // 1bpp, quantized "colors"
536 wxBMP_1BPP_BW = 2 // 1bpp, black & white from red
537};
f74ff5ef
RD
538
539
d14a1e28
RD
540class wxBMPHandler : public wxImageHandler {
541public:
542 wxBMPHandler();
543};
cf694132 544
d14a1e28
RD
545class wxICOHandler : public wxBMPHandler {
546public:
547 wxICOHandler();
548};
f74ff5ef 549
d14a1e28
RD
550class wxCURHandler : public wxICOHandler {
551public:
552 wxCURHandler();
553};
f74ff5ef 554
d14a1e28
RD
555class wxANIHandler : public wxCURHandler {
556public:
557 wxANIHandler();
558};
06c0fba4 559
0a651eb8 560
d14a1e28 561//---------------------------------------------------------------------------
0a651eb8 562
d14a1e28
RD
563class wxPNGHandler : public wxImageHandler {
564public:
565 wxPNGHandler();
566};
0a651eb8 567
0a651eb8 568
d14a1e28
RD
569class wxGIFHandler : public wxImageHandler {
570public:
571 wxGIFHandler();
572};
0a651eb8
RD
573
574
d14a1e28
RD
575class wxPCXHandler : public wxImageHandler {
576public:
577 wxPCXHandler();
578};
926bb76c 579
926bb76c 580
d14a1e28
RD
581class wxJPEGHandler : public wxImageHandler {
582public:
583 wxJPEGHandler();
584};
926bb76c 585
926bb76c 586
d14a1e28
RD
587class wxPNMHandler : public wxImageHandler {
588public:
589 wxPNMHandler();
590};
591
592class wxXPMHandler : public wxImageHandler {
593public:
594 wxXPMHandler();
595};
596
597class wxTIFFHandler : public wxImageHandler {
598public:
599 wxTIFFHandler();
600};
601
602
603#if wxUSE_IFF
604class wxIFFHandler : public wxImageHandler {
605public:
606 wxIFFHandler();
607};
608#endif
926bb76c 609
be43ef04
RD
610//---------------------------------------------------------------------------
611
612%{
613#include <wx/quantize.h>
614%}
615
616enum {
617 wxQUANTIZE_INCLUDE_WINDOWS_COLOURS,
618// wxQUANTIZE_RETURN_8BIT_DATA,
619 wxQUANTIZE_FILL_DESTINATION_IMAGE
620};
621
622
623DocStr(wxQuantize,
624 "Performs quantization, or colour reduction, on a wxImage.", "");
625
626class wxQuantize /*: public wxObject */
627{
628public:
629
630 %extend {
631 DocStr(
632 Quantize,
633 "Reduce the colours in the source image and put the result into the
39101468 634destination image, setting the palette in the destination if
be43ef04
RD
635needed. Both images may be the same, to overwrite the source image.", "
636:todo: Create a version that returns the wx.Palette used.");
637
638 static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236,
639 int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE)
640 {
641 return wxQuantize::Quantize(src, dest,
642 //NULL, // palette
643 desiredNoColours,
644 NULL, // eightBitData
645 flags);
646 }
647 }
648};
649
650
cf694132 651//---------------------------------------------------------------------------