]> git.saurik.com Git - wxWidgets.git/blob - wxPython/src/image.i
Added wxCURSOR_ARROWWAIT which is the default arrow+hourglass cursor
[wxWidgets.git] / wxPython / src / image.i
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: image.i
3 // Purpose: SWIG interface file for wxImage, wxImageHandler, etc.
4 //
5 // Author: Robin Dunn
6 //
7 // Created: 28-Apr-1999
8 // RCS-ID: $Id$
9 // Copyright: (c) 1998 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
12
13
14 %module image
15
16 %{
17 #include "helpers.h"
18 #include <wx/image.h>
19 %}
20
21 //----------------------------------------------------------------------
22
23 %include typemaps.i
24 %include my_typemaps.i
25
26 // Import some definitions of other classes, etc.
27 %import _defs.i
28 %import misc.i
29 %import gdi.i
30
31 //---------------------------------------------------------------------------
32
33 class wxImageHandler {
34 public:
35 // wxImageHandler(); Abstract Base Class
36 wxString GetName();
37 wxString GetExtension();
38 long GetType();
39 wxString GetMimeType();
40
41 //bool LoadFile(wxImage* image, wxInputStream& stream);
42 //bool SaveFile(wxImage* image, wxOutputStream& stream);
43
44 void SetName(const wxString& name);
45 void SetExtension(const wxString& extension);
46 void SetType(long type);
47 void SetMimeType(const wxString& mimetype);
48 };
49
50 //---------------------------------------------------------------------------
51
52 class wxPNGHandler : public wxImageHandler {
53 public:
54 wxPNGHandler();
55 };
56
57
58 class wxJPEGHandler : public wxImageHandler {
59 public:
60 wxJPEGHandler();
61 };
62
63
64 class wxBMPHandler : public wxImageHandler {
65 public:
66 wxBMPHandler();
67 };
68
69
70 class wxGIFHandler : public wxImageHandler {
71 public:
72 wxGIFHandler();
73 };
74
75 class wxPNMHandler : public wxImageHandler {
76 public:
77 wxPNMHandler();
78 };
79
80 class wxPCXHandler : public wxImageHandler {
81 public:
82 wxPCXHandler();
83 };
84
85 class wxTIFFHandler : public wxImageHandler {
86 public:
87 wxTIFFHandler();
88 };
89
90
91 //---------------------------------------------------------------------------
92
93 class wxImage {
94 public:
95 wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY );
96 ~wxImage();
97
98 wxBitmap ConvertToBitmap();
99 void Create( int width, int height );
100 void Destroy();
101 wxImage Scale( int width, int height );
102 wxImage& Rescale(int width, int height);
103
104 void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b );
105 unsigned char GetRed( int x, int y );
106 unsigned char GetGreen( int x, int y );
107 unsigned char GetBlue( int x, int y );
108
109 static bool CanRead( const wxString& name );
110 bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY );
111 %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype );
112
113 bool SaveFile( const wxString& name, int type );
114 %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype );
115
116 bool Ok();
117 int GetWidth();
118 int GetHeight();
119
120 wxImage GetSubImage(const wxRect& rect);
121 wxImage Copy();
122 void Paste( const wxImage &image, int x, int y );
123
124 //unsigned char *GetData();
125 //void SetData( unsigned char *data );
126
127 %addmethods {
128 PyObject* GetData() {
129 unsigned char* data = self->GetData();
130 int len = self->GetWidth() * self->GetHeight() * 3;
131 return PyString_FromStringAndSize((char*)data, len);
132 }
133
134 void SetData(PyObject* data) {
135 unsigned char* dataPtr;
136
137 if (! PyString_Check(data)) {
138 PyErr_SetString(PyExc_TypeError, "Expected string object");
139 return /* NULL */ ;
140 }
141
142 size_t len = self->GetWidth() * self->GetHeight() * 3;
143 dataPtr = (unsigned char*) malloc(len);
144 memcpy(dataPtr, PyString_AsString(data), len);
145 self->SetData(dataPtr);
146 }
147 }
148
149 void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
150 unsigned char GetMaskRed();
151 unsigned char GetMaskGreen();
152 unsigned char GetMaskBlue();
153 void SetMask( bool mask = TRUE );
154 bool HasMask();
155
156 wxImage Rotate(double angle, const wxPoint & centre_of_rotation,
157 bool interpolating = TRUE, wxPoint * offset_after_rotation = NULL) const ;
158 wxImage Rotate90( bool clockwise = TRUE ) ;
159 wxImage Mirror( bool horizontally = TRUE ) ;
160
161 void Replace( unsigned char r1, unsigned char g1, unsigned char b1,
162 unsigned char r2, unsigned char g2, unsigned char b2 );
163
164 unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
165 // TODO: unsigned long ComputeHistogram( wxHashTable &h );
166
167 static void AddHandler( wxImageHandler *handler );
168 static void InsertHandler( wxImageHandler *handler );
169 static bool RemoveHandler( const wxString& name );
170 };
171
172 // Alternate constructors
173 %new wxImage* wxNullImage();
174 %new wxImage* wxEmptyImage(int width, int height);
175 %new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype);
176 %new wxImage* wxImageFromBitmap(const wxBitmap &bitmap);
177 %{
178 wxImage* wxNullImage() {
179 return new wxImage;
180 }
181
182 wxImage* wxEmptyImage(int width, int height) {
183 return new wxImage(width, height);
184 }
185
186 wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) {
187 return new wxImage(name, mimetype);
188 }
189
190 wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
191 return new wxImage(bitmap);
192 }
193 %}
194
195
196 void wxInitAllImageHandlers();
197
198 //---------------------------------------------------------------------------
199 //---------------------------------------------------------------------------