X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9e9ee68e90212f1d9ba9f1cfa05e291463f6ae92..5526e819eca4465ed5520d49bccfebc6a28045e0:/include/wx/image.h diff --git a/include/wx/image.h b/include/wx/image.h index ffdcf30a2f..7db3f34479 100644 --- a/include/wx/image.h +++ b/include/wx/image.h @@ -4,7 +4,7 @@ // Author: Robert Roebling // RCS-ID: $Id$ // Copyright: (c) Robert Roebling -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_IMAGE_H_ @@ -18,9 +18,10 @@ #include "wx/object.h" #include "wx/string.h" #include "wx/gdicmn.h" +#include "wx/bitmap.h" #if wxUSE_STREAMS -#include "wx/stream.h" + #include "wx/stream.h" #endif //----------------------------------------------------------------------------- @@ -37,8 +38,6 @@ class WXDLLEXPORT wxJPEGHandler; class WXDLLEXPORT wxBMPHandler; class WXDLLEXPORT wxImage; -class WXDLLEXPORT wxBitmap; - //----------------------------------------------------------------------------- // wxImageHandler //----------------------------------------------------------------------------- @@ -46,7 +45,7 @@ class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxImageHandler: public wxObject { DECLARE_DYNAMIC_CLASS(wxImageHandler) - + public: wxImageHandler() { m_name = ""; m_extension = ""; m_type = 0; } @@ -69,7 +68,7 @@ protected: wxString m_extension; wxString m_mime; long m_type; - + }; //----------------------------------------------------------------------------- @@ -80,7 +79,7 @@ protected: class WXDLLEXPORT wxPNGHandler: public wxImageHandler { DECLARE_DYNAMIC_CLASS(wxPNGHandler) - + public: inline wxPNGHandler() @@ -95,7 +94,6 @@ public: virtual bool LoadFile( wxImage *image, wxInputStream& stream ); virtual bool SaveFile( wxImage *image, wxOutputStream& stream ); #endif - }; #endif @@ -118,8 +116,10 @@ public: m_mime = "image/jpeg"; }; +#if wxUSE_STREAMS virtual bool LoadFile( wxImage *image, wxInputStream& stream ); virtual bool SaveFile( wxImage *image, wxOutputStream& stream ); +#endif }; #endif @@ -130,7 +130,7 @@ public: class WXDLLEXPORT wxBMPHandler: public wxImageHandler { DECLARE_DYNAMIC_CLASS(wxBMPHandler) - + public: inline wxBMPHandler() @@ -146,6 +146,30 @@ public: #endif }; +//----------------------------------------------------------------------------- +// wxGIFHandler +//----------------------------------------------------------------------------- + +class WXDLLEXPORT wxGIFHandler : public wxImageHandler +{ + DECLARE_DYNAMIC_CLASS(wxGIFHandler) + +public: + + inline wxGIFHandler() + { + m_name = "GIF file"; + m_extension = "gif"; + m_type = wxBITMAP_TYPE_GIF; + m_mime = "image/gif"; + }; + +#if wxUSE_STREAMS + virtual bool LoadFile( wxImage *image, wxInputStream& stream ); + virtual bool SaveFile( wxImage *image, wxOutputStream& stream ); +#endif +}; + //----------------------------------------------------------------------------- // wxImage //----------------------------------------------------------------------------- @@ -167,22 +191,27 @@ public: wxImage( const wxImage& image ); wxImage( const wxImage* image ); - - // these functions get implemented in /src/(platform)/bitmap.cpp + + // these functions get implemented in /src/(platform)/bitmap.cpp wxImage( const wxBitmap &bitmap ); + operator wxBitmap() const { return ConvertToBitmap(); } wxBitmap ConvertToBitmap() const; void Create( int width, int height ); void Destroy(); - - wxImage Scale( int width, int height ); - - // these routines are slow but safe + + // return the new image with size width*height + wxImage Scale( int width, int height ) const; + + // rescales the image in place + void Rescale( int width, int height ) { *this = Scale(width, height); } + + // these routines are slow but safe void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ); unsigned char GetRed( int x, int y ); unsigned char GetGreen( int x, int y ); unsigned char GetBlue( int x, int y ); - + virtual bool LoadFile( const wxString& name, long type = wxBITMAP_TYPE_PNG ); virtual bool LoadFile( const wxString& name, const wxString& mimetype ); @@ -205,7 +234,7 @@ public: char unsigned *GetData() const; void SetData( char unsigned *data ); - + void SetMaskColour( unsigned char r, unsigned char g, unsigned char b ); unsigned char GetMaskRed() const; unsigned char GetMaskGreen() const; @@ -213,18 +242,19 @@ public: void SetMask( bool mask = TRUE ); bool HasMask() const; - inline wxImage& operator = (const wxImage& image) - { if ((*this) == image) - return (*this); + wxImage& operator = (const wxImage& image) + { + if ( (*this) != image ) Ref(image); - return *this; } + return *this; + } - inline bool operator == (const wxImage& image) + bool operator == (const wxImage& image) { return m_refData == image.m_refData; } - inline bool operator != (const wxImage& image) + bool operator != (const wxImage& image) { return m_refData != image.m_refData; } - static inline wxList& GetHandlers() { return sm_handlers; } + static wxList& GetHandlers() { return sm_handlers; } static void AddHandler( wxImageHandler *handler ); static void InsertHandler( wxImageHandler *handler ); static bool RemoveHandler( const wxString& name ); @@ -239,7 +269,7 @@ public: protected: static wxList sm_handlers; - + }; #endif