]>
Commit | Line | Data |
---|---|---|
cf694132 RD |
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(); | |
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 | ||
76 | ||
77 | //--------------------------------------------------------------------------- | |
78 | ||
79 | class wxImage { | |
80 | public: | |
81 | wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG ); | |
82 | ~wxImage(); | |
83 | ||
84 | wxBitmap ConvertToBitmap(); | |
85 | void Create( int width, int height ); | |
86 | void Destroy(); | |
87 | wxImage Scale( int width, int height ); | |
8bf5d46e | 88 | void Rescale(int width, int height); |
cf694132 RD |
89 | |
90 | void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ); | |
91 | unsigned char GetRed( int x, int y ); | |
92 | unsigned char GetGreen( int x, int y ); | |
93 | unsigned char GetBlue( int x, int y ); | |
94 | ||
95 | bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG ); | |
96 | %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype ); | |
97 | ||
98 | bool SaveFile( const wxString& name, int type ); | |
99 | %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype ); | |
100 | ||
101 | bool Ok(); | |
102 | int GetWidth(); | |
103 | int GetHeight(); | |
104 | ||
1dc2f865 RD |
105 | //unsigned char *GetData(); |
106 | //void SetData( unsigned char *data ); | |
107 | ||
108 | %addmethods { | |
109 | PyObject* GetData() { | |
110 | unsigned char* data = self->GetData(); | |
111 | int len = self->GetWidth() * self->GetHeight() * 3; | |
112 | return PyString_FromStringAndSize((char*)data, len); | |
113 | } | |
114 | ||
115 | void SetData(PyObject* data) { | |
116 | unsigned char* dataPtr; | |
117 | ||
118 | if (! PyString_Check(data)) { | |
119 | PyErr_SetString(PyExc_TypeError, "Expected string object"); | |
120 | return /* NULL */ ; | |
121 | } | |
122 | dataPtr = (unsigned char*)PyString_AsString(data); | |
123 | self->SetData(dataPtr); | |
124 | } | |
125 | } | |
cf694132 RD |
126 | |
127 | void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); | |
128 | unsigned char GetMaskRed(); | |
129 | unsigned char GetMaskGreen(); | |
130 | unsigned char GetMaskBlue(); | |
131 | void SetMask( bool mask = TRUE ); | |
132 | bool HasMask(); | |
133 | ||
134 | }; | |
135 | ||
136 | // Alternate constructors | |
137 | %new wxImage* wxNullImage(); | |
138 | %new wxImage* wxEmptyImage(int width, int height); | |
139 | %new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype); | |
140 | %new wxImage* wxImageFromBitmap(const wxBitmap &bitmap); | |
141 | %{ | |
142 | wxImage* wxNullImage() { | |
143 | return new wxImage; | |
144 | } | |
145 | ||
146 | wxImage* wxEmptyImage(int width, int height) { | |
147 | return new wxImage(width, height); | |
148 | } | |
149 | ||
150 | wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) { | |
151 | return new wxImage(name, mimetype); | |
152 | } | |
153 | ||
154 | wxImage* wxImageFromBitmap(const wxBitmap &bitmap) { | |
155 | return new wxImage(bitmap); | |
156 | } | |
157 | %} | |
158 | ||
159 | // Static Methods | |
160 | void wxImage_AddHandler(wxImageHandler *handler); | |
161 | %{ | |
162 | void wxImage_AddHandler(wxImageHandler *handler) { | |
163 | wxImage::AddHandler(handler); | |
164 | } | |
165 | %} | |
166 | ||
167 | //--------------------------------------------------------------------------- | |
168 | //--------------------------------------------------------------------------- | |
169 | ||
170 | ||
171 | ||
172 |