]>
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 { | |
dd9f7fea | 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); | |
dd9f7fea | 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 | ||
149 | ||
68bc8549 RD |
150 | // Set image's mask to the area of 'mask' that has <mr,mg,mb> colour |
151 | bool SetMaskFromImage(const wxImage & mask, | |
152 | byte mr, byte mg, byte mb); | |
153 | ||
db0ff83e RD |
154 | // void DoFloodFill (wxCoord x, wxCoord y, |
155 | // const wxBrush & fillBrush, | |
156 | // const wxColour& testColour, | |
157 | // int style = wxFLOOD_SURFACE, | |
158 | // int LogicalFunction = wxCOPY /* currently unused */ ) ; | |
68bc8549 | 159 | |
96bfd053 | 160 | static bool CanRead( const wxString& name ); |
b5a5d647 RD |
161 | static int GetImageCount( const wxString& name, long type = wxBITMAP_TYPE_ANY ); |
162 | ||
163 | bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ); | |
164 | %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype, int index = -1 ); | |
cf694132 RD |
165 | |
166 | bool SaveFile( const wxString& name, int type ); | |
167 | %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype ); | |
168 | ||
f74ff5ef RD |
169 | %name(CanReadStream) static bool CanRead( wxInputStream& stream ); |
170 | %name(LoadStream) bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1 ); | |
171 | %name(LoadMimeStream) bool LoadFile( wxInputStream& stream, const wxString& mimetype, int index = -1 ); | |
172 | ||
cf694132 RD |
173 | bool Ok(); |
174 | int GetWidth(); | |
175 | int GetHeight(); | |
176 | ||
ba938c3d RD |
177 | %extend { |
178 | wxSize GetSize() { | |
179 | wxSize size(self->GetWidth(), self->GetHeight()); | |
180 | return size; | |
181 | } | |
182 | } | |
183 | ||
9d8bd15f | 184 | wxImage GetSubImage(const wxRect& rect); |
f6bcfd97 BP |
185 | wxImage Copy(); |
186 | void Paste( const wxImage &image, int x, int y ); | |
9d8bd15f | 187 | |
1dc2f865 RD |
188 | //unsigned char *GetData(); |
189 | //void SetData( unsigned char *data ); | |
190 | ||
d14a1e28 | 191 | %extend { |
9cbf6f6e | 192 | PyObject* GetData() { |
d55d6b3f RD |
193 | unsigned char* data = self->GetData(); |
194 | int len = self->GetWidth() * self->GetHeight() * 3; | |
d14a1e28 RD |
195 | PyObject* rv; |
196 | wxPyBLOCK_THREADS( rv = PyString_FromStringAndSize((char*)data, len)); | |
197 | return rv; | |
d55d6b3f | 198 | } |
9cbf6f6e RD |
199 | void SetData(PyObject* data) { |
200 | unsigned char* dataPtr; | |
d55d6b3f | 201 | |
9cbf6f6e | 202 | if (! PyString_Check(data)) { |
debff7aa RD |
203 | wxPyBLOCK_THREADS(PyErr_SetString(PyExc_TypeError, |
204 | "Expected string object")); | |
9cbf6f6e RD |
205 | return /* NULL */ ; |
206 | } | |
207 | ||
208 | size_t len = self->GetWidth() * self->GetHeight() * 3; | |
209 | dataPtr = (unsigned char*) malloc(len); | |
d14a1e28 | 210 | wxPyBLOCK_THREADS( memcpy(dataPtr, PyString_AsString(data), len) ); |
9cbf6f6e RD |
211 | self->SetData(dataPtr); |
212 | // wxImage takes ownership of dataPtr... | |
213 | } | |
214 | ||
215 | ||
216 | ||
217 | PyObject* GetDataBuffer() { | |
1dc2f865 RD |
218 | unsigned char* data = self->GetData(); |
219 | int len = self->GetWidth() * self->GetHeight() * 3; | |
d14a1e28 RD |
220 | PyObject* rv; |
221 | wxPyBLOCK_THREADS( rv = PyBuffer_FromReadWriteMemory(data, len) ); | |
222 | return rv; | |
1dc2f865 | 223 | } |
1e4a197e RD |
224 | void SetDataBuffer(PyObject* data) { |
225 | unsigned char* buffer; | |
226 | int size; | |
227 | ||
da32eb53 | 228 | bool blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
229 | if (!PyArg_Parse(data, "t#", &buffer, &size)) |
230 | goto done; | |
1e4a197e RD |
231 | |
232 | if (size != self->GetWidth() * self->GetHeight() * 3) { | |
233 | PyErr_SetString(PyExc_TypeError, "Incorrect buffer size"); | |
d14a1e28 | 234 | goto done; |
1e4a197e | 235 | } |
1e4a197e | 236 | self->SetData(buffer); |
d14a1e28 | 237 | done: |
da32eb53 | 238 | wxPyEndBlockThreads(blocked); |
1e4a197e RD |
239 | } |
240 | ||
9cbf6f6e RD |
241 | |
242 | ||
243 | PyObject* GetAlphaData() { | |
244 | unsigned char* data = self->GetAlpha(); | |
245 | if (! data) { | |
246 | RETURN_NONE(); | |
247 | } else { | |
248 | int len = self->GetWidth() * self->GetHeight(); | |
d14a1e28 RD |
249 | PyObject* rv; |
250 | wxPyBLOCK_THREADS( rv = PyString_FromStringAndSize((char*)data, len) ); | |
251 | return rv; | |
9cbf6f6e RD |
252 | } |
253 | } | |
254 | void SetAlphaData(PyObject* data) { | |
1dc2f865 RD |
255 | unsigned char* dataPtr; |
256 | ||
257 | if (! PyString_Check(data)) { | |
258 | PyErr_SetString(PyExc_TypeError, "Expected string object"); | |
259 | return /* NULL */ ; | |
260 | } | |
9d8bd15f | 261 | |
9cbf6f6e | 262 | size_t len = self->GetWidth() * self->GetHeight(); |
185d7c3e | 263 | dataPtr = (unsigned char*) malloc(len); |
d14a1e28 | 264 | wxPyBLOCK_THREADS( memcpy(dataPtr, PyString_AsString(data), len) ); |
9cbf6f6e | 265 | self->SetAlpha(dataPtr); |
3b5ccda1 | 266 | // wxImage takes ownership of dataPtr... |
1dc2f865 | 267 | } |
9cbf6f6e RD |
268 | |
269 | ||
270 | ||
271 | PyObject* GetAlphaBuffer() { | |
272 | unsigned char* data = self->GetAlpha(); | |
273 | int len = self->GetWidth() * self->GetHeight(); | |
d14a1e28 RD |
274 | PyObject* rv; |
275 | wxPyBLOCK_THREADS( rv = PyBuffer_FromReadWriteMemory(data, len) ); | |
276 | return rv; | |
9cbf6f6e RD |
277 | } |
278 | void SetAlphaBuffer(PyObject* data) { | |
279 | unsigned char* buffer; | |
280 | int size; | |
281 | ||
da32eb53 | 282 | bool blocked = wxPyBeginBlockThreads(); |
d14a1e28 RD |
283 | if (!PyArg_Parse(data, "t#", &buffer, &size)) |
284 | goto done; | |
9cbf6f6e RD |
285 | |
286 | if (size != self->GetWidth() * self->GetHeight()) { | |
287 | PyErr_SetString(PyExc_TypeError, "Incorrect buffer size"); | |
d14a1e28 | 288 | goto done; |
9cbf6f6e RD |
289 | } |
290 | self->SetAlpha(buffer); | |
d14a1e28 | 291 | done: |
da32eb53 | 292 | wxPyEndBlockThreads(blocked); |
9cbf6f6e | 293 | } |
1dc2f865 | 294 | } |
cf694132 RD |
295 | |
296 | void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); | |
297 | unsigned char GetMaskRed(); | |
298 | unsigned char GetMaskGreen(); | |
299 | unsigned char GetMaskBlue(); | |
dd9f7fea | 300 | void SetMask( bool mask = True ); |
cf694132 RD |
301 | bool HasMask(); |
302 | ||
f6bcfd97 | 303 | wxImage Rotate(double angle, const wxPoint & centre_of_rotation, |
dd9f7fea RD |
304 | bool interpolating = True, wxPoint * offset_after_rotation = NULL) const ; |
305 | wxImage Rotate90( bool clockwise = True ) ; | |
306 | wxImage Mirror( bool horizontally = True ) ; | |
f6bcfd97 BP |
307 | |
308 | void Replace( unsigned char r1, unsigned char g1, unsigned char b1, | |
309 | unsigned char r2, unsigned char g2, unsigned char b2 ); | |
310 | ||
6c0168c9 RD |
311 | // convert to monochrome image (<r,g,b> will be replaced by white, everything else by black) |
312 | wxImage ConvertToMono( unsigned char r, unsigned char g, unsigned char b ) const; | |
313 | ||
314 | void SetOption(const wxString& name, const wxString& value); | |
315 | %name(SetOptionInt)void SetOption(const wxString& name, int value); | |
316 | wxString GetOption(const wxString& name) const; | |
317 | int GetOptionInt(const wxString& name) const; | |
318 | bool HasOption(const wxString& name) const; | |
319 | ||
f6bcfd97 | 320 | unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 ); |
9cbf6f6e | 321 | unsigned long ComputeHistogram( wxImageHistogram& h ); |
f6bcfd97 | 322 | |
96bfd053 RD |
323 | static void AddHandler( wxImageHandler *handler ); |
324 | static void InsertHandler( wxImageHandler *handler ); | |
325 | static bool RemoveHandler( const wxString& name ); | |
3ef86e32 | 326 | static wxString GetImageExtWildcard(); |
b96c7a38 RD |
327 | |
328 | ||
ab1f7d2a RD |
329 | MustHaveApp(ConvertToBitmap); |
330 | MustHaveApp(ConvertToMonoBitmap); | |
be43ef04 | 331 | |
d14a1e28 | 332 | %extend { |
12523ae4 RD |
333 | wxBitmap ConvertToBitmap(int depth=-1) { |
334 | wxBitmap bitmap(*self, depth); | |
b96c7a38 RD |
335 | return bitmap; |
336 | } | |
337 | ||
338 | wxBitmap ConvertToMonoBitmap( unsigned char red, | |
339 | unsigned char green, | |
340 | unsigned char blue ) { | |
341 | wxImage mono = self->ConvertToMono( red, green, blue ); | |
342 | wxBitmap bitmap( mono, 1 ); | |
343 | return bitmap; | |
344 | } | |
345 | } | |
1fded56b | 346 | |
d14a1e28 | 347 | %pythoncode { def __nonzero__(self): return self.Ok() } |
cf694132 RD |
348 | }; |
349 | ||
926bb76c | 350 | |
f74ff5ef | 351 | |
a3150741 RD |
352 | ///void wxInitAllImageHandlers(); |
353 | ||
354 | %pythoncode { | |
355 | def InitAllImageHandlers(): | |
356 | """ | |
357 | The former functionality of InitAllImageHanders is now done internal to | |
358 | the _core_ extension module and so this function has become a simple NOP. | |
359 | """ | |
360 | pass | |
361 | } | |
362 | ||
cf694132 | 363 | |
f74ff5ef | 364 | |
d14a1e28 RD |
365 | // See also wxPy_ReinitStockObjects in helpers.cpp |
366 | %immutable; | |
367 | const wxImage wxNullImage; | |
368 | %mutable; | |
cf694132 | 369 | |
d14a1e28 | 370 | //--------------------------------------------------------------------------- |
f74ff5ef | 371 | |
b5a5d647 | 372 | |
d14a1e28 RD |
373 | MAKE_CONST_WXSTRING(IMAGE_OPTION_BMP_FORMAT); |
374 | MAKE_CONST_WXSTRING(IMAGE_OPTION_CUR_HOTSPOT_X); | |
375 | MAKE_CONST_WXSTRING(IMAGE_OPTION_CUR_HOTSPOT_Y); | |
376 | MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTION); | |
be43ef04 | 377 | MAKE_CONST_WXSTRING(IMAGE_OPTION_RESOLUTIONUNIT); |
f74ff5ef | 378 | |
d14a1e28 RD |
379 | enum |
380 | { | |
381 | wxIMAGE_RESOLUTION_INCHES = 1, | |
382 | wxIMAGE_RESOLUTION_CM = 2 | |
383 | }; | |
f74ff5ef RD |
384 | |
385 | ||
d14a1e28 RD |
386 | enum |
387 | { | |
388 | wxBMP_24BPP = 24, // default, do not need to set | |
389 | //wxBMP_16BPP = 16, // wxQuantize can only do 236 colors? | |
390 | wxBMP_8BPP = 8, // 8bpp, quantized colors | |
391 | wxBMP_8BPP_GREY = 9, // 8bpp, rgb averaged to greys | |
392 | wxBMP_8BPP_GRAY = wxBMP_8BPP_GREY, | |
393 | wxBMP_8BPP_RED = 10, // 8bpp, red used as greyscale | |
394 | wxBMP_8BPP_PALETTE = 11, // 8bpp, use the wxImage's palette | |
395 | wxBMP_4BPP = 4, // 4bpp, quantized colors | |
396 | wxBMP_1BPP = 1, // 1bpp, quantized "colors" | |
397 | wxBMP_1BPP_BW = 2 // 1bpp, black & white from red | |
398 | }; | |
f74ff5ef RD |
399 | |
400 | ||
d14a1e28 RD |
401 | class wxBMPHandler : public wxImageHandler { |
402 | public: | |
403 | wxBMPHandler(); | |
404 | }; | |
cf694132 | 405 | |
d14a1e28 RD |
406 | class wxICOHandler : public wxBMPHandler { |
407 | public: | |
408 | wxICOHandler(); | |
409 | }; | |
f74ff5ef | 410 | |
d14a1e28 RD |
411 | class wxCURHandler : public wxICOHandler { |
412 | public: | |
413 | wxCURHandler(); | |
414 | }; | |
f74ff5ef | 415 | |
d14a1e28 RD |
416 | class wxANIHandler : public wxCURHandler { |
417 | public: | |
418 | wxANIHandler(); | |
419 | }; | |
06c0fba4 | 420 | |
0a651eb8 | 421 | |
d14a1e28 | 422 | //--------------------------------------------------------------------------- |
0a651eb8 | 423 | |
d14a1e28 RD |
424 | class wxPNGHandler : public wxImageHandler { |
425 | public: | |
426 | wxPNGHandler(); | |
427 | }; | |
0a651eb8 | 428 | |
0a651eb8 | 429 | |
d14a1e28 RD |
430 | class wxGIFHandler : public wxImageHandler { |
431 | public: | |
432 | wxGIFHandler(); | |
433 | }; | |
0a651eb8 RD |
434 | |
435 | ||
d14a1e28 RD |
436 | class wxPCXHandler : public wxImageHandler { |
437 | public: | |
438 | wxPCXHandler(); | |
439 | }; | |
926bb76c | 440 | |
926bb76c | 441 | |
d14a1e28 RD |
442 | class wxJPEGHandler : public wxImageHandler { |
443 | public: | |
444 | wxJPEGHandler(); | |
445 | }; | |
926bb76c | 446 | |
926bb76c | 447 | |
d14a1e28 RD |
448 | class wxPNMHandler : public wxImageHandler { |
449 | public: | |
450 | wxPNMHandler(); | |
451 | }; | |
452 | ||
453 | class wxXPMHandler : public wxImageHandler { | |
454 | public: | |
455 | wxXPMHandler(); | |
456 | }; | |
457 | ||
458 | class wxTIFFHandler : public wxImageHandler { | |
459 | public: | |
460 | wxTIFFHandler(); | |
461 | }; | |
462 | ||
463 | ||
464 | #if wxUSE_IFF | |
465 | class wxIFFHandler : public wxImageHandler { | |
466 | public: | |
467 | wxIFFHandler(); | |
468 | }; | |
469 | #endif | |
926bb76c | 470 | |
be43ef04 RD |
471 | //--------------------------------------------------------------------------- |
472 | ||
473 | %{ | |
474 | #include <wx/quantize.h> | |
475 | %} | |
476 | ||
477 | enum { | |
478 | wxQUANTIZE_INCLUDE_WINDOWS_COLOURS, | |
479 | // wxQUANTIZE_RETURN_8BIT_DATA, | |
480 | wxQUANTIZE_FILL_DESTINATION_IMAGE | |
481 | }; | |
482 | ||
483 | ||
484 | DocStr(wxQuantize, | |
485 | "Performs quantization, or colour reduction, on a wxImage.", ""); | |
486 | ||
487 | class wxQuantize /*: public wxObject */ | |
488 | { | |
489 | public: | |
490 | ||
491 | %extend { | |
492 | DocStr( | |
493 | Quantize, | |
494 | "Reduce the colours in the source image and put the result into the | |
39101468 | 495 | destination image, setting the palette in the destination if |
be43ef04 RD |
496 | needed. Both images may be the same, to overwrite the source image.", " |
497 | :todo: Create a version that returns the wx.Palette used."); | |
498 | ||
499 | static bool Quantize(const wxImage& src, wxImage& dest, int desiredNoColours = 236, | |
500 | int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE) | |
501 | { | |
502 | return wxQuantize::Quantize(src, dest, | |
503 | //NULL, // palette | |
504 | desiredNoColours, | |
505 | NULL, // eightBitData | |
506 | flags); | |
507 | } | |
508 | } | |
509 | }; | |
510 | ||
511 | ||
cf694132 | 512 | //--------------------------------------------------------------------------- |