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