X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f74ff5efa5604fcde3cc5ba9009cb015a6f388cf..e422162882bf4c5ae743fd618864e97206765fca:/wxPython/src/image.i diff --git a/wxPython/src/image.i b/wxPython/src/image.i index 457887f7f1..ab9ccc65e9 100644 --- a/wxPython/src/image.i +++ b/wxPython/src/image.i @@ -15,6 +15,7 @@ %{ #include "helpers.h" +#include "pyistream.h" #include %} @@ -115,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(); @@ -130,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 ); @@ -155,6 +167,12 @@ public: //void SetData( unsigned char *data ); %addmethods { + PyObject* GetDataBuffer() { + unsigned char* data = self->GetData(); + int len = self->GetWidth() * self->GetHeight() * 3; + return PyBuffer_FromReadWriteMemory(data, len); + } + PyObject* GetData() { unsigned char* data = self->GetData(); int len = self->GetWidth() * self->GetHeight() * 3; @@ -206,6 +224,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; + } + } }; @@ -232,7 +266,7 @@ public: wxImage* wxImageFromBitmap(const wxBitmap &bitmap) { - return new wxImage(bitmap); + return new wxImage(bitmap.ConvertToImage()); }