1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file for wxImage, wxImageHandler, etc.
7 // Created: 28-Apr-1999
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
21 //----------------------------------------------------------------------
24 %include my_typemaps.i
26 // Import some definitions of other classes, etc.
31 //---------------------------------------------------------------------------
33 class wxImageHandler : public wxObject {
35 // wxImageHandler(); Abstract Base Class
37 wxString GetExtension();
39 wxString GetMimeType();
41 //bool LoadFile(wxImage* image, wxInputStream& stream);
42 //bool SaveFile(wxImage* image, wxOutputStream& stream);
44 void SetName(const wxString& name);
45 void SetExtension(const wxString& extension);
46 void SetType(long type);
47 void SetMimeType(const wxString& mimetype);
50 //---------------------------------------------------------------------------
52 class wxPNGHandler : public wxImageHandler {
58 class wxJPEGHandler : public wxImageHandler {
64 class wxBMPHandler : public wxImageHandler {
70 class wxGIFHandler : public wxImageHandler {
75 class wxPNMHandler : public wxImageHandler {
80 class wxPCXHandler : public wxImageHandler {
85 class wxTIFFHandler : public wxImageHandler {
91 //---------------------------------------------------------------------------
93 class wxImage : public wxObject {
95 wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY );
98 wxBitmap ConvertToBitmap();
100 wxBitmap ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ) const;
102 void Create( int width, int height );
105 wxImage Scale( int width, int height );
106 wxImage& Rescale(int width, int height);
108 void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
109 unsigned char GetRed( int x, int y );
110 unsigned char GetGreen( int x, int y );
111 unsigned char GetBlue( int x, int y );
113 static bool CanRead( const wxString& name );
114 bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY );
115 %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype );
117 bool SaveFile( const wxString& name, int type );
118 %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype );
124 wxImage GetSubImage(const wxRect& rect);
126 void Paste( const wxImage &image, int x, int y );
128 //unsigned char *GetData();
129 //void SetData( unsigned char *data );
132 PyObject* GetData() {
133 unsigned char* data = self->GetData();
134 int len = self->GetWidth() * self->GetHeight() * 3;
135 return PyString_FromStringAndSize((char*)data, len);
138 void SetData(PyObject* data) {
139 unsigned char* dataPtr;
141 if (! PyString_Check(data)) {
142 PyErr_SetString(PyExc_TypeError, "Expected string object");
146 size_t len = self->GetWidth() * self->GetHeight() * 3;
147 dataPtr = (unsigned char*) malloc(len);
148 memcpy(dataPtr, PyString_AsString(data), len);
149 self->SetData(dataPtr);
153 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
154 unsigned char GetMaskRed();
155 unsigned char GetMaskGreen();
156 unsigned char GetMaskBlue();
157 void SetMask( bool mask = TRUE );
160 wxImage Rotate(double angle, const wxPoint & centre_of_rotation,
161 bool interpolating = TRUE, wxPoint * offset_after_rotation = NULL) const ;
162 wxImage Rotate90( bool clockwise = TRUE ) ;
163 wxImage Mirror( bool horizontally = TRUE ) ;
165 void Replace( unsigned char r1, unsigned char g1, unsigned char b1,
166 unsigned char r2, unsigned char g2, unsigned char b2 );
168 // convert to monochrome image (<r,g,b> will be replaced by white, everything else by black)
169 wxImage ConvertToMono( unsigned char r, unsigned char g, unsigned char b ) const;
171 void SetOption(const wxString& name, const wxString& value);
172 %name(SetOptionInt)void SetOption(const wxString& name, int value);
173 wxString GetOption(const wxString& name) const;
174 int GetOptionInt(const wxString& name) const;
175 bool HasOption(const wxString& name) const;
177 unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
178 // TODO: unsigned long ComputeHistogram( wxHashTable &h );
180 static void AddHandler( wxImageHandler *handler );
181 static void InsertHandler( wxImageHandler *handler );
182 static bool RemoveHandler( const wxString& name );
186 // Alternate constructors
187 %new wxImage* wxEmptyImage(int width=0, int height=0);
188 %new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype);
189 %new wxImage* wxImageFromBitmap(const wxBitmap &bitmap);
191 wxImage* wxEmptyImage(int width=0, int height=0) {
192 if (width == 0 && height == 0)
195 return new wxImage(width, height);
198 wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) {
199 return new wxImage(name, mimetype);
202 wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
203 return new wxImage(bitmap);
207 void wxInitAllImageHandlers();
215 extern wxImage wxNullImage;
224 //---------------------------------------------------------------------------
225 // This one is here to avoid circular imports
227 %new wxBitmap* wxBitmapFromImage(const wxImage& img, int depth=-1);
230 wxBitmap* wxBitmapFromImage(const wxImage& img, int depth=-1) {
231 return new wxBitmap(img, depth);
237 //---------------------------------------------------------------------------