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