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