X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b5a5d6473c0f5339854a4105a57c6a733632f073..32b70aec1ff90877ae0ce2ce82967f698218fbdc:/wxPython/src/image.i diff --git a/wxPython/src/image.i b/wxPython/src/image.i index adcf9ebaa6..837336efe8 100644 --- a/wxPython/src/image.i +++ b/wxPython/src/image.i @@ -15,6 +15,7 @@ %{ #include "helpers.h" +#include "pyistream.h" #include %} @@ -27,6 +28,7 @@ %import _defs.i %import misc.i %import gdi.i +%import streams.i //--------------------------------------------------------------------------- @@ -75,6 +77,16 @@ public: wxICOHandler(); }; +class wxCURHandler : public wxICOHandler { +public: + wxCURHandler(); +}; + +class wxANIHandler : public wxCURHandler { +public: + wxANIHandler(); +}; + class wxGIFHandler : public wxImageHandler { public: wxGIFHandler(); @@ -96,6 +108,7 @@ public: }; + //--------------------------------------------------------------------------- class wxImage : public wxObject { @@ -103,10 +116,6 @@ public: wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1 ); ~wxImage(); - wxBitmap ConvertToBitmap(); // deprecated -#ifdef __WXGTK__ - wxBitmap ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ) const; -#endif void Create( int width, int height ); void Destroy(); @@ -118,6 +127,21 @@ public: unsigned char GetGreen( int x, int y ); unsigned char GetBlue( int x, int y ); + // find first colour that is not used in the image and has higher + // RGB values than + bool FindFirstUnusedColour( byte *OUTPUT, byte *OUTPUT, byte *OUTPUT, + byte startR = 0, byte startG = 0, byte startB = 0 ) const; + + // Set image's mask to the area of 'mask' that has colour + bool SetMaskFromImage(const wxImage & mask, + byte mr, byte mg, byte mb); + +// void DoFloodFill (wxCoord x, wxCoord y, +// const wxBrush & fillBrush, +// const wxColour& testColour, +// int style = wxFLOOD_SURFACE, +// int LogicalFunction = wxCOPY /* currently unused */ ) ; + static bool CanRead( const wxString& name ); static int GetImageCount( const wxString& name, long type = wxBITMAP_TYPE_ANY ); @@ -127,6 +151,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(); @@ -190,6 +218,22 @@ public: static void AddHandler( wxImageHandler *handler ); static void InsertHandler( wxImageHandler *handler ); static bool RemoveHandler( const wxString& name ); + + + %addmethods { + wxBitmap ConvertToBitmap() { + wxBitmap bitmap(*self); + return bitmap; + } + + wxBitmap ConvertToMonoBitmap( unsigned char red, + unsigned char green, + unsigned char blue ) { + wxImage mono = self->ConvertToMono( red, green, blue ); + wxBitmap bitmap( mono, 1 ); + return bitmap; + } + } }; @@ -198,6 +242,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) @@ -206,14 +253,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); + return new wxImage(bitmap.ConvertToImage()); } + 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); @@ -224,8 +274,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();