X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6bcfd974ef26faf6f91a62cac09827e09463fd1..16d38102e8ad5534d185cc532b9aa8077a75e0a4:/wxPython/src/image.i diff --git a/wxPython/src/image.i b/wxPython/src/image.i index fd8ba4d8b2..37757eeb54 100644 --- a/wxPython/src/image.i +++ b/wxPython/src/image.i @@ -30,7 +30,7 @@ //--------------------------------------------------------------------------- -class wxImageHandler { +class wxImageHandler : public wxObject { public: // wxImageHandler(); Abstract Base Class wxString GetName(); @@ -90,12 +90,15 @@ public: //--------------------------------------------------------------------------- -class wxImage { +class wxImage : public wxObject { public: wxImage( const wxString& name, long type = wxBITMAP_TYPE_ANY ); ~wxImage(); wxBitmap ConvertToBitmap(); +#ifdef __WXGTK__ + wxBitmap ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ) const; +#endif void Create( int width, int height ); void Destroy(); wxImage Scale( int width, int height ); @@ -106,7 +109,8 @@ public: unsigned char GetGreen( int x, int y ); unsigned char GetBlue( int x, int y ); - bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG ); + static bool CanRead( const wxString& name ); + bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_ANY ); %name(LoadMimeFile)bool LoadFile( const wxString& name, const wxString& mimetype ); bool SaveFile( const wxString& name, int type ); @@ -139,7 +143,7 @@ public: } size_t len = self->GetWidth() * self->GetHeight() * 3; - dataPtr = new unsigned char[len]; + dataPtr = (unsigned char*) malloc(len); memcpy(dataPtr, PyString_AsString(data), len); self->SetData(dataPtr); } @@ -163,20 +167,22 @@ public: unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 ); // TODO: unsigned long ComputeHistogram( wxHashTable &h ); + static void AddHandler( wxImageHandler *handler ); + static void InsertHandler( wxImageHandler *handler ); + static bool RemoveHandler( const wxString& name ); }; + // Alternate constructors -%new wxImage* wxNullImage(); -%new wxImage* wxEmptyImage(int width, int height); +%new wxImage* wxEmptyImage(int width=0, int height=0); %new wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype); %new wxImage* wxImageFromBitmap(const wxBitmap &bitmap); %{ - wxImage* wxNullImage() { - return new wxImage; - } - - wxImage* wxEmptyImage(int width, int height) { - return new wxImage(width, height); + wxImage* wxEmptyImage(int width=0, int height=0) { + if (width == 0 && height == 0) + return new wxImage; + else + return new wxImage(width, height); } wxImage* wxImageFromMime(const wxString& name, const wxString& mimetype) { @@ -188,15 +194,34 @@ public: } %} -// Static Methods -void wxImage_AddHandler(wxImageHandler *handler); +void wxInitAllImageHandlers(); + + +%readonly %{ - void wxImage_AddHandler(wxImageHandler *handler) { - wxImage::AddHandler(handler); - } +#if 0 %} -void wxInitAllImageHandlers(); +extern wxImage wxNullImage; + +%readwrite +%{ +#endif +%} + + //--------------------------------------------------------------------------- +// This one is here to avoid circular imports + +%new wxBitmap* wxBitmapFromImage(const wxImage& img, int depth=-1); + +%{ + wxBitmap* wxBitmapFromImage(const wxImage& img, int depth=-1) { + return new wxBitmap(img, depth); + } + +%} + + //---------------------------------------------------------------------------