]>
Commit | Line | Data |
---|---|---|
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 | 26 | class wxImageHandler : public wxObject { |
cf694132 | 27 | public: |
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 |
50 | class wxImageHistogram /* : public wxImageHistogramBase */ |
51 | { | |
06c0fba4 | 52 | public: |
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 |
69 | values than startR, startG, startB. Returns a tuple consisting of a | |
70 | success flag and rgb values.", ""); | |
9b3d3bc4 RD |
71 | }; |
72 | ||
73 | ||
cf694132 RD |
74 | //--------------------------------------------------------------------------- |
75 | ||
d14a1e28 | 76 | |
9416aa89 | 77 | class wxImage : public wxObject { |
cf694132 | 78 | public: |
b5a5d647 | 79 | wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ); |
cf694132 RD |
80 | ~wxImage(); |
81 | ||
d14a1e28 RD |
82 | // Alternate constructors |
83 | %name(ImageFromMime) wxImage(const wxString& name, const wxString& mimetype, int index = -1); | |
84 | %name(ImageFromStream) wxImage(wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1); | |
85 | %name(ImageFromStreamMime) wxImage(wxInputStream& stream, const wxString& mimetype, int index = -1 ); | |
86 | %extend { | |
a72f4631 | 87 | %name(EmptyImage) wxImage(int width=0, int height=0, bool clear = true) { |
d14a1e28 RD |
88 | if (width > 0 && height > 0) |
89 | return new wxImage(width, height, clear); | |
90 | else | |
91 | return new wxImage; | |
be43ef04 | 92 | } |
ab1f7d2a RD |
93 | |
94 | MustHaveApp(wxImage(const wxBitmap &bitmap)); | |
d14a1e28 RD |
95 | %name(ImageFromBitmap) wxImage(const wxBitmap &bitmap) { |
96 | return new wxImage(bitmap.ConvertToImage()); | |
97 | } | |
be43ef04 | 98 | |
d14a1e28 RD |
99 | %name(ImageFromData) wxImage(int width, int height, unsigned char* data) { |
100 | // Copy the source data so the wxImage can clean it up later | |
101 | unsigned char* copy = (unsigned char*)malloc(width*height*3); | |
102 | if (copy == NULL) { | |
103 | PyErr_NoMemory(); | |
104 | return NULL; | |
105 | } | |
106 | memcpy(copy, data, width*height*3); | |
a72f4631 | 107 | return new wxImage(width, height, copy, false); |
d14a1e28 RD |
108 | } |
109 | } | |
be43ef04 | 110 | |
cf694132 RD |
111 | void Create( int width, int height ); |
112 | void Destroy(); | |
6c0168c9 | 113 | |
cf694132 | 114 | wxImage Scale( int width, int height ); |
9cbf6f6e | 115 | wxImage ShrinkBy( int xFactor , int yFactor ) const ; |
f6bcfd97 | 116 | wxImage& Rescale(int width, int height); |
cf694132 RD |
117 | |
118 | void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ); | |
119 | unsigned char GetRed( int x, int y ); | |
120 | unsigned char GetGreen( int x, int y ); | |
121 | unsigned char GetBlue( int x, int y ); | |
122 | ||
9cbf6f6e RD |
123 | void SetAlpha(int x, int y, unsigned char alpha); |
124 | unsigned char GetAlpha(int x, int y); | |
125 | bool HasAlpha(); | |
126 | ||
127 | // find first colour that is not used in the image and has higher | |
68bc8549 | 128 | // RGB values than <startR,startG,startB> |
dd9f7fea RD |
129 | DocDeclAStr( |
130 | bool, FindFirstUnusedColour( byte *OUTPUT, byte *OUTPUT, byte *OUTPUT, | |
131 | byte startR = 0, byte startG = 0, byte startB = 0 ) const, | |
132 | "FindFirstUnusedColour(int startR=1, int startG=0, int startB=0) -> (success, r, g, b)", | |
d07d2bc9 RD |
133 | "Find first colour that is not used in the image and has higher RGB |
134 | values than startR, startG, startB. Returns a tuple consisting of a | |
135 | success flag and rgb values.", ""); | |
dd9f7fea | 136 | |
125c972b RD |
137 | |
138 | DocDeclStr( | |
139 | bool , ConvertAlphaToMask(byte threshold = 128), | |
140 | "If the image has alpha channel, this method converts it to mask. All pixels | |
141 | with alpha value less than ``threshold`` are replaced with mask colour and the | |
142 | alpha channel is removed. Mask colour is chosen automatically using | |
143 | `FindFirstUnusedColour`. | |
144 | ||
145 | If the image image doesn't have alpha channel, ConvertAlphaToMask does | |
146 | nothing.", ""); | |
147 | ||
148 | ||
6f7ecb3b RD |
149 | DocDeclStr( |
150 | bool , ConvertColourToAlpha( unsigned char r, unsigned char g, unsigned char b ), | |
151 | "This method converts an image where the original alpha information is | |
152 | only available as a shades of a colour (actually shades of grey) | |
153 | typically when you draw anti-aliased text into a bitmap. The DC | |
154 | drawing routines draw grey values on the black background although | |
155 | they actually mean to draw white with differnt alpha values. This | |
156 | method reverses it, assuming a black (!) background and white text. | |
157 | The method will then fill up the whole image with the colour given.", ""); | |
158 | ||
159 | ||
125c972b | 160 | |
68bc8549 RD |
161 | // Set image's mask to the area of 'mask' that has <mr,mg,mb> colour |
162 | bool SetMaskFromImage(const wxImage & mask, | |
163 | byte mr, byte mg, byte mb); | |
164 | ||
db0ff83e RD |
165 | // void DoFloodFill (wxCoord x, wxCoord y, |
166 | // const wxBrush & fillBrush, | |
167 | // const wxColour& testColour, | |
168 | // int style = wxFLOOD_SURFACE, | |
169 | // int LogicalFunction = wxCOPY /* currently unused */ ) ; | |
68bc8549 | 170 | |
96bfd053 | 171 | static bool CanRead( const wxString& name ); |
b5a5d647 RD |
172 | static int GetImageCount( const wxString& name, long type = wxBITMAP_TYPE_ANY ); |
173 | ||
174 | bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ); | |
175 | %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype, int index = -1 ); | |
cf694132 RD |
176 | |
177 | bool SaveFile( const wxString& name, int type ); | |
178 | %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype ); | |
179 | ||
f74ff5ef RD |
180 | %name(CanReadStream) static bool CanRead( wxInputStream& stream ); |
181 | %name(LoadStream) bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1 ); | |
182 | %name(LoadMimeStream) bool LoadFile( wxInputStream& stream, const wxString& mimetype, int index = -1 ); | |
183 | ||
cf694132 RD |
184 | bool Ok(); |
185 | int GetWidth(); | |
186 | int GetHeight(); | |
187 | ||
ba938c3d RD |
188 | %extend { |
189 | wxSize GetSize() { | |
190 | wxSize size(self->GetWidth(), self->GetHeight()); | |
191 | return size; | |
192 | } | |
193 | } | |
194 | ||
9d8bd15f | 195 | wxImage GetSubImage(const wxRect& rect); |
f6bcfd97 BP |
196 | wxImage Copy(); |
197 | void Paste( const wxImage &image, int x, int y ); | |
9d8bd15f | 198 | |
1dc2f865 RD |
199 | //unsigned char *GetData(); |
200 | //void SetData( unsigned char *data ); | |
201 | ||
d14a1e28 | 202 | %extend { |
9cbf6f6e | 203 | PyObject* GetData() { |
d55d6b3f RD |
204 | unsigned char* data = self->GetData(); |
205 | int len = self->GetWidth() * self->GetHeight() * 3; | |
d14a1e28 RD |
206 | PyObject* rv; |
207 | wxPyBLOCK_THREADS( rv = PyString_FromStringAndSize((char*)data, len)); | |
208 | return rv; | |
d55d6b3f | 209 | } |
9cbf6f6e RD |
210 | void SetData(PyObject* data) { |
211 | unsigned char* dataPtr; | |
d55d6b3f | 212 | |
9cbf6f6e | 213 | if (! PyString_Check(data)) { |
debff7aa RD |
214 | wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError, |
215 | "Expected string object")); | |
9cbf6f6e RD |
216 | return /* NULL */ ; |
217 | } | |
218 | ||
219 | size_t len = self->GetWidth() * self->GetHeight() * 3; | |
220 | dataPtr = (unsigned char*) malloc(len); | |
d14a1e28 | 221 | wxPyBLOCK_THREADS( memcpy(dataPtr, PyString_AsString(data), len) ); |
9cbf6f6e RD |
222 | self->SetData(dataPtr); |
223 | // wxImage takes ownership of dataPtr... | |
224 | } | |
225 | ||
226 | ||
227 | ||
228 | PyObject* GetDataBuffer() { | |
1dc2f865 RD |
229 | unsigned char* data = self->GetData(); |
230 | int len = self->GetWidth() * self->GetHeight() * 3; | |
d14a1e28 RD |
231 | PyObject* rv; |
232 | wxPyBLOCK_THREADS( rv = PyBuffer_FromReadWriteMemory(data, len) ); | |
233 | return rv; | |
1dc2f865 | 234 | } |
1e4a197e RD |
235 | void SetDataBuffer(PyObject* data) { |
236 | unsigned char* buffer; | |
237 | int size; | |
238 | ||
da32eb53 | 239 | bool blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
240 | if (!PyArg_Parse(data, "t#", &buffer, &size)) |
241 | goto done; | |
1e4a197e RD |
242 | |
243 | if (size != self->GetWidth() * self->GetHeight() * 3) { | |
244 | PyErr_SetString(PyExc_TypeError, "Incorrect buffer size"); | |
d14a1e28 | 245 | goto done; |
1e4a197e | 246 | } |
1e4a197e | 247 | self->SetData(buffer); |
d14a1e28 | 248 | done: |
da32eb53 | 249 | wxPyEndBlockThreads(blocked); |
1e4a197e RD |
250 | } |
251 | ||
9cbf6f6e RD |
252 | |
253 | ||
254 | PyObject* GetAlphaData() { | |
255 | unsigned char* data = self->GetAlpha(); | |
256 | if (! data) { | |
257 | RETURN_NONE(); | |
258 | } else { | |
259 | int len = self->GetWidth() * self->GetHeight(); | |
d14a1e28 RD |
260 | PyObject* rv; |
261 | wxPyBLOCK_THREADS( rv = PyString_FromStringAndSize((char*)data, len) ); | |
262 | return rv; | |
9cbf6f6e RD |
263 | } |
264 | } | |
265 | void SetAlphaData(PyObject* data) { | |
1dc2f865 RD |
266 | unsigned char* dataPtr; |
267 | ||
268 | if (! PyString_Check(data)) { | |
269 | PyErr_SetString(PyExc_TypeError, "Expected string object"); | |
270 | return /* NULL */ ; | |
271 | } | |
9d8bd15f | 272 | |
9cbf6f6e | 273 | size_t len = self->GetWidth() * self->GetHeight(); |
185d7c3e | 274 | dataPtr = (unsigned char*) malloc(len); |
d14a1e28 | 275 | wxPyBLOCK_THREADS( memcpy(dataPtr, PyString_AsString(data), len) ); |
9cbf6f6e | 276 | self->SetAlpha(dataPtr); |
3b5ccda1 | 277 | // wxImage takes ownership of dataPtr... |
1dc2f865 | 278 | } |
9cbf6f6e RD |
279 | |
280 | ||
281 | ||
282 | PyObject* GetAlphaBuffer() { | |
283 | unsigned char* data = self->GetAlpha(); | |
284 | int len = self->GetWidth() * self->GetHeight(); | |
d14a1e28 RD |
285 | PyObject* rv; |
286 | wxPyBLOCK_THREADS( rv = PyBuffer_FromReadWriteMemory(data, len) ); | |
287 | return rv; | |
9cbf6f6e RD |
288 | } |
289 | void SetAlphaBuffer(PyObject* data) { | |
290 | unsigned char* buffer; | |
291 | int size; | |
292 | ||
da32eb53 | 293 | bool blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
294 | if (!PyArg_Parse(data, "t#", &buffer, &size)) |
295 | goto done; | |
9cbf6f6e RD |
296 | |
297 | if (size != self->GetWidth() * self->GetHeight()) { | |
298 | PyErr_SetString(PyExc_TypeError, "Incorrect buffer size"); | |
d14a1e28 | 299 | goto done; |
9cbf6f6e RD |
300 | } |
301 | self->SetAlpha(buffer); | |
d14a1e28 | 302 | done: |
da32eb53 | 303 | wxPyEndBlockThreads(blocked); |
9cbf6f6e | 304 | } |
1dc2f865 | 305 | } |
cf694132 RD |
306 | |
307 | void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); | |
308 | unsigned char GetMaskRed(); | |
309 | unsigned char GetMaskGreen(); | |
310 | unsigned char GetMaskBlue(); | |
a72f4631 | 311 | void SetMask( bool mask = true ); |
cf694132 RD |
312 | bool HasMask(); |
313 | ||
f6bcfd97 | 314 | wxImage Rotate(double angle, const wxPoint & centre_of_rotation, |
a72f4631 RD |
315 | bool interpolating = true, wxPoint * offset_after_rotation = NULL) const ; |
316 | wxImage Rotate90( bool clockwise = true ) ; | |
317 | wxImage Mirror( bool horizontally = true ) ; | |
f6bcfd97 BP |
318 | |
319 | void Replace( unsigned char r1, unsigned char g1, unsigned char b1, | |
320 | unsigned char r2, unsigned char g2, unsigned char b2 ); | |
321 | ||
6c0168c9 RD |
322 | // convert to monochrome image (<r,g,b> will be replaced by white, everything else by black) |
323 | wxImage ConvertToMono( unsigned char r, unsigned char g, unsigned char b ) const; | |
324 | ||
325 | void SetOption(const wxString& name, const wxString& value); | |
326 | %name(SetOptionInt)void SetOption(const wxString& name, int value); | |
327 | wxString GetOption(const wxString& name) const; | |
328 | int GetOptionInt(const wxString& name) const; | |
329 | bool HasOption(const wxString& name) const; | |
330 | ||
f6bcfd97 | 331 | unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 ); |
9cbf6f6e | 332 | unsigned long ComputeHistogram( wxImageHistogram& h ); |
f6bcfd97 | 333 | |
96bfd053 RD |
334 | static void AddHandler( wxImageHandler *handler ); |
335 | static void InsertHandler( wxImageHandler *handler ); | |
336 | static bool RemoveHandler( const wxString& name ); | |
3ef86e32 | 337 | static wxString GetImageExtWildcard(); |
b96c7a38 RD |
338 | |
339 | ||
ab1f7d2a RD |
340 | MustHaveApp(ConvertToBitmap); |
341 | MustHaveApp(ConvertToMonoBitmap); | |
be43ef04 | 342 | |
d14a1e28 | 343 | %extend { |
12523ae4 RD |
344 | wxBitmap ConvertToBitmap(int depth=-1) { |
345 | wxBitmap bitmap(*self, depth); | |
b96c7a38 RD |
346 | return bitmap; |
347 | } | |
348 | ||
349 | wxBitmap ConvertToMonoBitmap( unsigned char red, | |
350 | unsigned char green, | |
351 | unsigned char blue ) { | |
352 | wxImage mono = self->ConvertToMono( red, green, blue ); | |
353 | wxBitmap bitmap( mono, 1 ); | |
354 | return bitmap; | |
355 | } | |
356 | } | |
1fded56b | 357 | |
d14a1e28 | 358 | %pythoncode { def __nonzero__(self): return self.Ok() } |
cf694132 RD |
359 | }; |
360 | ||
926bb76c | 361 | |
f74ff5ef | 362 | |
a3150741 RD |
363 | ///void wxInitAllImageHandlers(); |
364 | ||
365 | %pythoncode { | |
366 | def InitAllImageHandlers(): | |
367 | """ | |
368 | The former functionality of InitAllImageHanders is now done internal to | |
369 | the _core_ extension module and so this function has become a simple NOP. | |
370 | """ | |
371 | pass | |
372 | } | |
373 | ||
cf694132 | 374 | |
f74ff5ef | 375 | |
d14a1e28 RD |
376 | // See also wxPy_ReinitStockObjects in helpers.cpp |
377 | %immutable; | |
378 | const wxImage wxNullImage; | |
379 | %mutable; | |
cf694132 | 380 | |
d14a1e28 | 381 | //--------------------------------------------------------------------------- |
f74ff5ef | 382 | |
b5a5d647 | 383 | |
d14a1e28 RD |
384 | MAKE_CONST_WXSTRING(IMAGE_OPTION_BMP_FORMAT); |
385 | MAKE_CONST_WXSTRING(IMAGE_OPTION_CUR_HOTSPOT_X); | |
386 | MAKE_CONST_WXSTRING(IMAGE_OPTION_CUR_HOTSPOT_Y); | |
387 | MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTION); | |
be43ef04 | 388 | MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTIONUNIT); |
f74ff5ef | 389 | |
d14a1e28 RD |
390 | enum |
391 | { | |
392 | wxIMAGE_RESOLUTION_INCHES = 1, | |
393 | wxIMAGE_RESOLUTION_CM = 2 | |
394 | }; | |
f74ff5ef RD |
395 | |
396 | ||
d14a1e28 RD |
397 | enum |
398 | { | |
399 | wxBMP_24BPP = 24, // default, do not need to set | |
400 | //wxBMP_16BPP = 16, // wxQuantize can only do 236 colors? | |
401 | wxBMP_8BPP = 8, // 8bpp, quantized colors | |
402 | wxBMP_8BPP_GREY = 9, // 8bpp, rgb averaged to greys | |
403 | wxBMP_8BPP_GRAY = wxBMP_8BPP_GREY, | |
404 | wxBMP_8BPP_RED = 10, // 8bpp, red used as greyscale | |
405 | wxBMP_8BPP_PALETTE = 11, // 8bpp, use the wxImage's palette | |
406 | wxBMP_4BPP = 4, // 4bpp, quantized colors | |
407 | wxBMP_1BPP = 1, // 1bpp, quantized "colors" | |
408 | wxBMP_1BPP_BW = 2 // 1bpp, black & white from red | |
409 | }; | |
f74ff5ef RD |
410 | |
411 | ||
d14a1e28 RD |
412 | class wxBMPHandler : public wxImageHandler { |
413 | public: | |
414 | wxBMPHandler(); | |
415 | }; | |
cf694132 | 416 | |
d14a1e28 RD |
417 | class wxICOHandler : public wxBMPHandler { |
418 | public: | |
419 | wxICOHandler(); | |
420 | }; | |
f74ff5ef | 421 | |
d14a1e28 RD |
422 | class wxCURHandler : public wxICOHandler { |
423 | public: | |
424 | wxCURHandler(); | |
425 | }; | |
f74ff5ef | 426 | |
d14a1e28 RD |
427 | class wxANIHandler : public wxCURHandler { |
428 | public: | |
429 | wxANIHandler(); | |
430 | }; | |
06c0fba4 | 431 | |
0a651eb8 | 432 | |
d14a1e28 | 433 | //--------------------------------------------------------------------------- |
0a651eb8 | 434 | |
d14a1e28 RD |
435 | class wxPNGHandler : public wxImageHandler { |
436 | public: | |
437 | wxPNGHandler(); | |
438 | }; | |
0a651eb8 | 439 | |
0a651eb8 | 440 | |
d14a1e28 RD |
441 | class wxGIFHandler : public wxImageHandler { |
442 | public: | |
443 | wxGIFHandler(); | |
444 | }; | |
0a651eb8 RD |
445 | |
446 | ||
d14a1e28 RD |
447 | class wxPCXHandler : public wxImageHandler { |
448 | public: | |
449 | wxPCXHandler(); | |
450 | }; | |
926bb76c | 451 | |
926bb76c | 452 | |
d14a1e28 RD |
453 | class wxJPEGHandler : public wxImageHandler { |
454 | public: | |
455 | wxJPEGHandler(); | |
456 | }; | |
926bb76c | 457 | |
926bb76c | 458 | |
d14a1e28 RD |
459 | class wxPNMHandler : public wxImageHandler { |
460 | public: | |
461 | wxPNMHandler(); | |
462 | }; | |
463 | ||
464 | class wxXPMHandler : public wxImageHandler { | |
465 | public: | |
466 | wxXPMHandler(); | |
467 | }; | |
468 | ||
469 | class wxTIFFHandler : public wxImageHandler { | |
470 | public: | |
471 | wxTIFFHandler(); | |
472 | }; | |
473 | ||
474 | ||
475 | #if wxUSE_IFF | |
476 | class wxIFFHandler : public wxImageHandler { | |
477 | public: | |
478 | wxIFFHandler(); | |
479 | }; | |
480 | #endif | |
926bb76c | 481 | |
be43ef04 RD |
482 | //--------------------------------------------------------------------------- |
483 | ||
484 | %{ | |
485 | #include <wx/quantize.h> | |
486 | %} | |
487 | ||
488 | enum { | |
489 | wxQUANTIZE_INCLUDE_WINDOWS_COLOURS, | |
490 | // wxQUANTIZE_RETURN_8BIT_DATA, | |
491 | wxQUANTIZE_FILL_DESTINATION_IMAGE | |
492 | }; | |
493 | ||
494 | ||
495 | DocStr(wxQuantize, | |
496 | "Performs quantization, or colour reduction, on a wxImage.", ""); | |
497 | ||
498 | class wxQuantize /*: public wxObject */ | |
499 | { | |
500 | public: | |
501 | ||
502 | %extend { | |
503 | DocStr( | |
504 | Quantize, | |
505 | "Reduce the colours in the source image and put the result into the | |
39101468 | 506 | destination image, setting the palette in the destination if |
be43ef04 RD |
507 | needed. Both images may be the same, to overwrite the source image.", " |
508 | :todo: Create a version that returns the wx.Palette used."); | |
509 | ||
510 | static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236, | |
511 | int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE) | |
512 | { | |
513 | return wxQuantize::Quantize(src, dest, | |
514 | //NULL, // palette | |
515 | desiredNoColours, | |
516 | NULL, // eightBitData | |
517 | flags); | |
518 | } | |
519 | } | |
520 | }; | |
521 | ||
522 | ||
cf694132 | 523 | //--------------------------------------------------------------------------- |