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 {
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 //---------------------------------------------------------------------------
89 wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG );
92 wxBitmap ConvertToBitmap();
93 void Create( int width, int height );
95 wxImage Scale( int width, int height );
96 void Rescale(int width, int height);
98 void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
99 unsigned char GetRed( int x, int y );
100 unsigned char GetGreen( int x, int y );
101 unsigned char GetBlue( int x, int y );
103 bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG );
104 %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype );
106 bool SaveFile( const wxString& name, int type );
107 %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype );
113 wxImage GetSubImage(const wxRect& rect);
115 //unsigned char *GetData();
116 //void SetData( unsigned char *data );
119 PyObject* GetData() {
120 unsigned char* data = self->GetData();
121 int len = self->GetWidth() * self->GetHeight() * 3;
122 return PyString_FromStringAndSize((char*)data, len);
125 void SetData(PyObject* data) {
126 unsigned char* dataPtr;
128 if (! PyString_Check(data)) {
129 PyErr_SetString(PyExc_TypeError, "Expected string object");
133 size_t len = self->GetWidth() * self->GetHeight() * 3;
134 dataPtr = new unsigned char[len];
135 memcpy(dataPtr, PyString_AsString(data), len);
136 self->SetData(dataPtr);
140 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
141 unsigned char GetMaskRed();
142 unsigned char GetMaskGreen();
143 unsigned char GetMaskBlue();
144 void SetMask( bool mask = TRUE );
149 // Alternate constructors
150 %new wxImage* wxNullImage();
151 %new wxImage* wxEmptyImage(int width, int height);
152 %new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype);
153 %new wxImage* wxImageFromBitmap(const wxBitmap &bitmap);
155 wxImage* wxNullImage() {
159 wxImage* wxEmptyImage(int width, int height) {
160 return new wxImage(width, height);
163 wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) {
164 return new wxImage(name, mimetype);
167 wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
168 return new wxImage(bitmap);
173 void wxImage_AddHandler(wxImageHandler *handler);
175 void wxImage_AddHandler(wxImageHandler *handler) {
176 wxImage::AddHandler(handler);
180 void wxInitAllImageHandlers();
182 //---------------------------------------------------------------------------
183 //---------------------------------------------------------------------------