Finished wrapping and providing typemaps for wxInputStream and also

added the stream ctor and other methods for wxImage so images can now
be loaded from any Python "file-like" object.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14365 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-02-23 19:50:01 +00:00
parent e531b73f89
commit f74ff5efa5
12 changed files with 714 additions and 688 deletions

View File

@@ -27,6 +27,7 @@
%import _defs.i
%import misc.i
%import gdi.i
%import streams.i
//---------------------------------------------------------------------------
@@ -138,6 +139,10 @@ public:
bool SaveFile( const wxString& name, int type );
%name(SaveMimeFile)bool SaveFile( const wxString& name, const wxString& mimetype );
%name(CanReadStream) static bool CanRead( wxInputStream& stream );
%name(LoadStream) bool LoadFile( wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1 );
%name(LoadMimeStream) bool LoadFile( wxInputStream& stream, const wxString& mimetype, int index = -1 );
bool Ok();
int GetWidth();
int GetHeight();
@@ -209,6 +214,9 @@ public:
%new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype, int index = -1);
%new wxImage* wxImageFromBitmap(const wxBitmap &bitmap);
%new wxImage* wxImageFromData(int width, int height, unsigned char* data);
%new wxImage* wxImageFromStream(wxInputStream& stream, long type = wxBITMAP_TYPE_ANY, int index = -1);
%new wxImage* wxImageFromStreamMime(wxInputStream& stream, const wxString& mimetype, int index = -1 );
%{
wxImage* wxEmptyImage(int width=0, int height=0) {
if (width == 0 && height == 0)
@@ -217,14 +225,17 @@ public:
return new wxImage(width, height);
}
wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype, int index) {
return new wxImage(name, mimetype, index);
}
wxImage* wxImageFromBitmap(const wxBitmap &bitmap) {
return new wxImage(bitmap);
}
wxImage* wxImageFromData(int width, int height, unsigned char* data) {
// Copy the source data so the wxImage can clean it up later
unsigned char* copy = (unsigned char*)malloc(width*height*3);
@@ -235,8 +246,22 @@ public:
memcpy(copy, data, width*height*3);
return new wxImage(width, height, copy, FALSE);
}
wxImage* wxImageFromStream(wxInputStream& stream,
long type = wxBITMAP_TYPE_ANY, int index = -1) {
return new wxImage(stream, type, index);
}
wxImage* wxImageFromStreamMime(wxInputStream& stream,
const wxString& mimetype, int index = -1 ) {
return new wxImage(stream, mimetype, index);
}
%}
void wxInitAllImageHandlers();