]> git.saurik.com Git - wxWidgets.git/blame - utils/wxPython/src/image.i
Added a constructor that allows creation of independent wxControl
[wxWidgets.git] / utils / 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
33class wxImageHandler {
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
RD
84
85//---------------------------------------------------------------------------
86
87class wxImage {
88public:
89 wxImage( const wxString& name, long type = wxBITMAP_TYPE_PNG );
90 ~wxImage();
91
92 wxBitmap ConvertToBitmap();
93 void Create( int width, int height );
94 void Destroy();
95 wxImage Scale( int width, int height );
8bf5d46e 96 void Rescale(int width, int height);
cf694132
RD
97
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 );
102
103 bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG );
104 %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype );
105
106 bool SaveFile( const wxString& name, int type );
107 %name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype );
108
109 bool Ok();
110 int GetWidth();
111 int GetHeight();
112
9d8bd15f
RD
113 wxImage GetSubImage(const wxRect& rect);
114
1dc2f865
RD
115 //unsigned char *GetData();
116 //void SetData( unsigned char *data );
117
118 %addmethods {
119 PyObject* GetData() {
120 unsigned char* data = self->GetData();
121 int len = self->GetWidth() * self->GetHeight() * 3;
122 return PyString_FromStringAndSize((char*)data, len);
123 }
124
125 void SetData(PyObject* data) {
126 unsigned char* dataPtr;
127
128 if (! PyString_Check(data)) {
129 PyErr_SetString(PyExc_TypeError, "Expected string object");
130 return /* NULL */ ;
131 }
9d8bd15f
RD
132
133 size_t len = self->GetWidth() * self->GetHeight() * 3;
134 dataPtr = new unsigned char[len];
135 memcpy(dataPtr, PyString_AsString(data), len);
1dc2f865
RD
136 self->SetData(dataPtr);
137 }
138 }
cf694132
RD
139
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 );
145 bool HasMask();
146
147};
148
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);
154%{
155 wxImage* wxNullImage() {
156 return new wxImage;
157 }
158
159 wxImage* wxEmptyImage(int width, int height) {
160 return new wxImage(width, height);
161 }
162
163 wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) {
164 return new wxImage(name, mimetype);
165 }
166
167 wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
168 return new wxImage(bitmap);
169 }
170%}
171
172// Static Methods
173void wxImage_AddHandler(wxImageHandler *handler);
174%{
175 void wxImage_AddHandler(wxImageHandler *handler) {
176 wxImage::AddHandler(handler);
177 }
178%}
179
06c0fba4
RD
180void wxInitAllImageHandlers();
181
cf694132
RD
182//---------------------------------------------------------------------------
183//---------------------------------------------------------------------------