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