]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/image.i
SWIGged files updates for wxMac
[wxWidgets.git] / wxPython / src / image.i
CommitLineData
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
9416aa89 33class wxImageHandler : public wxObject {
cf694132 34public:
1dec68aa 35 // wxImageHandler(); Abstract Base Class
cf694132
RD
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
52class wxPNGHandler : public wxImageHandler {
53public:
54 wxPNGHandler();
55};
56
57
58class wxJPEGHandler : public wxImageHandler {
59public:
60 wxJPEGHandler();
61};
62
63
64class wxBMPHandler : public wxImageHandler {
65public:
66 wxBMPHandler();
67};
68
69
70class wxGIFHandler : public wxImageHandler {
71public:
72 wxGIFHandler();
73};
74
06c0fba4
RD
75class wxPNMHandler : public wxImageHandler {
76public:
77 wxPNMHandler();
78};
cf694132 79
06c0fba4
RD
80class wxPCXHandler : public wxImageHandler {
81public:
82 wxPCXHandler();
83};
cf694132 84
9b3d3bc4
RD
85class wxTIFFHandler : public wxImageHandler {
86public:
87 wxTIFFHandler();
88};
89
90
cf694132
RD
91//---------------------------------------------------------------------------
92
9416aa89 93class wxImage : public wxObject {
cf694132 94public:
f6bcfd97 95 wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY );
cf694132
RD
96 ~wxImage();
97
98 wxBitmap ConvertToBitmap();
926bb76c
RD
99#ifdef __WXGTK__
100 wxBitmap ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ) const;
101#endif
cf694132
RD
102 void Create( int width, int height );
103 void Destroy();
6c0168c9 104
cf694132 105 wxImage Scale( int width, int height );
f6bcfd97 106 wxImage& Rescale(int width, int height);
cf694132
RD
107
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 );
112
96bfd053
RD
113 static bool CanRead( const wxString& name );
114 bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY );
cf694132
RD
115 %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype );
116
117 bool SaveFile( const wxString& name, int type );
118 %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype );
119
120 bool Ok();
121 int GetWidth();
122 int GetHeight();
123
9d8bd15f 124 wxImage GetSubImage(const wxRect& rect);
f6bcfd97
BP
125 wxImage Copy();
126 void Paste( const wxImage &image, int x, int y );
9d8bd15f 127
1dc2f865
RD
128 //unsigned char *GetData();
129 //void SetData( unsigned char *data );
130
131 %addmethods {
132 PyObject* GetData() {
133 unsigned char* data = self->GetData();
134 int len = self->GetWidth() * self->GetHeight() * 3;
135 return PyString_FromStringAndSize((char*)data, len);
136 }
137
138 void SetData(PyObject* data) {
139 unsigned char* dataPtr;
140
141 if (! PyString_Check(data)) {
142 PyErr_SetString(PyExc_TypeError, "Expected string object");
143 return /* NULL */ ;
144 }
9d8bd15f
RD
145
146 size_t len = self->GetWidth() * self->GetHeight() * 3;
185d7c3e 147 dataPtr = (unsigned char*) malloc(len);
9d8bd15f 148 memcpy(dataPtr, PyString_AsString(data), len);
1dc2f865
RD
149 self->SetData(dataPtr);
150 }
151 }
cf694132
RD
152
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 );
158 bool HasMask();
159
f6bcfd97
BP
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 ) ;
164
165 void Replace( unsigned char r1, unsigned char g1, unsigned char b1,
166 unsigned char r2, unsigned char g2, unsigned char b2 );
167
6c0168c9
RD
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;
170
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;
176
f6bcfd97
BP
177 unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
178 // TODO: unsigned long ComputeHistogram( wxHashTable &h );
179
96bfd053
RD
180 static void AddHandler( wxImageHandler *handler );
181 static void InsertHandler( wxImageHandler *handler );
182 static bool RemoveHandler( const wxString& name );
cf694132
RD
183};
184
926bb76c 185
cf694132 186// Alternate constructors
0a651eb8 187%new wxImage* wxEmptyImage(int width=0, int height=0);
cf694132
RD
188%new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype);
189%new wxImage* wxImageFromBitmap(const wxBitmap &bitmap);
190%{
0a651eb8
RD
191 wxImage* wxEmptyImage(int width=0, int height=0) {
192 if (width == 0 && height == 0)
193 return new wxImage;
194 else
195 return new wxImage(width, height);
cf694132
RD
196 }
197
198 wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) {
199 return new wxImage(name, mimetype);
200 }
201
202 wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
203 return new wxImage(bitmap);
204 }
205%}
206
06c0fba4
RD
207void wxInitAllImageHandlers();
208
0a651eb8
RD
209
210%readonly
211%{
212#if 0
213%}
214
215extern wxImage wxNullImage;
216
217%readwrite
218%{
219#endif
220%}
221
222
223
cf694132 224//---------------------------------------------------------------------------
926bb76c
RD
225// This one is here to avoid circular imports
226
227%new wxBitmap* wxBitmapFromImage(const wxImage& img, int depth=-1);
228
229%{
230 wxBitmap* wxBitmapFromImage(const wxImage& img, int depth=-1) {
231 return new wxBitmap(img, depth);
232 }
233
234%}
235
236
cf694132 237//---------------------------------------------------------------------------