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