From fd85921189610501e38fb501801b1eb6b9560fe7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 4 Apr 2001 23:15:36 +0000 Subject: [PATCH] I moved platform specific code from wxImage to wxBitmap git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9658 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/bitmap.h | 5 +++++ include/wx/gtk1/bitmap.h | 5 +++++ include/wx/image.h | 7 +++++++ include/wx/mac/bitmap.h | 7 +++++++ include/wx/motif/bitmap.h | 8 ++++++++ include/wx/msw/bitmap.h | 9 +++++++++ include/wx/os2/bitmap.h | 7 +++++++ 7 files changed, 48 insertions(+) diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index 41959d5ba6..a6c24d9c06 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -27,6 +27,7 @@ class wxMask; class wxBitmap; +class wxImage; //----------------------------------------------------------------------------- // wxMask @@ -68,6 +69,7 @@ public: wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); } wxBitmap( const wxBitmap& bmp ); wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM ); + wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } ~wxBitmap(); wxBitmap& operator = ( const wxBitmap& bmp ); bool operator == ( const wxBitmap& bmp ) const; @@ -79,6 +81,8 @@ public: int GetHeight() const; int GetWidth() const; int GetDepth() const; + + wxImage ConvertToImage() const; wxMask *GetMask() const; void SetMask( wxMask *mask ); @@ -106,6 +110,7 @@ public: protected: bool CreateFromXpm(const char **bits); + bool CreateFromImage(const wxImage& image, int depth); private: DECLARE_DYNAMIC_CLASS(wxBitmap) diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index 41959d5ba6..a6c24d9c06 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -27,6 +27,7 @@ class wxMask; class wxBitmap; +class wxImage; //----------------------------------------------------------------------------- // wxMask @@ -68,6 +69,7 @@ public: wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); } wxBitmap( const wxBitmap& bmp ); wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM ); + wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } ~wxBitmap(); wxBitmap& operator = ( const wxBitmap& bmp ); bool operator == ( const wxBitmap& bmp ) const; @@ -79,6 +81,8 @@ public: int GetHeight() const; int GetWidth() const; int GetDepth() const; + + wxImage ConvertToImage() const; wxMask *GetMask() const; void SetMask( wxMask *mask ); @@ -106,6 +110,7 @@ public: protected: bool CreateFromXpm(const char **bits); + bool CreateFromImage(const wxImage& image, int depth); private: DECLARE_DYNAMIC_CLASS(wxBitmap) diff --git a/include/wx/image.h b/include/wx/image.h index 7e872e3911..44a63769c2 100644 --- a/include/wx/image.h +++ b/include/wx/image.h @@ -98,11 +98,14 @@ public: wxImage( const wxImage& image ); wxImage( const wxImage* image ); +#if wxUSE_GUI + // convertion to/from wxBitmap (deprecated, use wxBitmap's methods instead): wxImage( const wxBitmap &bitmap ); operator wxBitmap() const { return ConvertToBitmap(); } wxBitmap ConvertToBitmap() const; #ifdef __WXGTK__ wxBitmap ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue ); +#endif #endif void Create( int width, int height ); @@ -137,6 +140,9 @@ public: // replace one colour with another void Replace( unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2 ); + + // convert to monochrome image ( will be replaced by white, everything else by black) + wxImage ConvertToMono( unsigned char r, unsigned char g, unsigned char b ); // these routines are slow but safe void SetRGB( int x, int y, unsigned char r, unsigned char g, unsigned char b ); @@ -229,6 +235,7 @@ private: extern void WXDLLEXPORT wxInitAllImageHandlers(); +WXDLLEXPORT_DATA(extern wxImage) wxNullImage; //----------------------------------------------------------------------------- // wxImage handlers diff --git a/include/wx/mac/bitmap.h b/include/wx/mac/bitmap.h index 85eaf59e81..84e7153375 100644 --- a/include/wx/mac/bitmap.h +++ b/include/wx/mac/bitmap.h @@ -27,6 +27,7 @@ class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxBitmapHandler; class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxCursor; +class WXDLLEXPORT wxImage; GWorldPtr wxMacCreateGWorld( int width , int height , int depth ) ; void wxMacDestroyGWorld( GWorldPtr gw ) ; @@ -152,7 +153,13 @@ public: // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1); + + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1); + ~wxBitmap(); + + wxImage ConvertToImage() const; // get the given part of bitmap wxBitmap GetSubBitmap( const wxRect& rect ) const; diff --git a/include/wx/motif/bitmap.h b/include/wx/motif/bitmap.h index 1af6e40347..785509cb69 100644 --- a/include/wx/motif/bitmap.h +++ b/include/wx/motif/bitmap.h @@ -27,6 +27,7 @@ class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxBitmapHandler; class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxCursor; +class WXDLLEXPORT wxImage; // A mask is a mono bitmap used for drawing bitmaps // transparently. @@ -155,6 +156,10 @@ public: // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1); + + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); } + ~wxBitmap(); virtual bool Create(int width, int height, int depth = -1); @@ -164,6 +169,8 @@ public: virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_XPM); virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); + + wxImage ConvertToImage() const; bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); } int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); } @@ -212,6 +219,7 @@ protected: protected: bool CreateFromXpm(const char **bits); + bool CreateFromImage(const wxImage& image, int depth); }; // Creates a bitmap with transparent areas drawn in diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index 7b9820cbb0..d96f86a163 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -28,6 +28,7 @@ class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxMask; class WXDLLEXPORT wxCursor; class WXDLLEXPORT wxControl; +class WXDLLEXPORT wxImage; // ---------------------------------------------------------------------------- // Bitmap data @@ -89,6 +90,9 @@ public: // If depth is omitted, will create a bitmap compatible with the display wxBitmap(int width, int height, int depth = -1); + + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); } // we must have this, otherwise icons are silently copied into bitmaps using // the copy ctor but the resulting bitmap is invalid! @@ -117,6 +121,8 @@ public: virtual ~wxBitmap(); + wxImage ConvertToImage() const; + // get the given part of bitmap wxBitmap GetSubBitmap( const wxRect& rect ) const; @@ -185,6 +191,9 @@ protected: // creates the bitmap from XPM data, supposed to be called from ctor bool CreateFromXpm(const char **bits); + // creates the bitmap from wxImage, supposed to be called from ctor + bool CreateFromImage(const wxImage& image, int depth); + private: #ifdef __WIN32__ diff --git a/include/wx/os2/bitmap.h b/include/wx/os2/bitmap.h index baacd60aa8..ba920a1fac 100644 --- a/include/wx/os2/bitmap.h +++ b/include/wx/os2/bitmap.h @@ -29,6 +29,7 @@ class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxMask; class WXDLLEXPORT wxCursor; class WXDLLEXPORT wxControl; +class WXDLLEXPORT wxImage; // ---------------------------------------------------------------------------- // Bitmap data @@ -105,6 +106,9 @@ public: ,int nDepth = -1 ); + wxBitmap( const wxImage& image, int depth = -1 ) + { (void)CreateFromImage(image, depth); } + // we must have this, otherwise icons are silently copied into bitmaps using // the copy ctor but the resulting bitmap is invalid! inline wxBitmap(const wxIcon& rIcon) @@ -132,6 +136,8 @@ public: virtual ~wxBitmap(); + wxImage ConvertToImage() const; + // get the given part of bitmap wxBitmap GetSubBitmap(const wxRect& rRect) const; @@ -226,6 +232,7 @@ protected: // creates the bitmap from XPM data, supposed to be called from ctor bool CreateFromXpm(const char **bits); + bool CreateFromImage(const wxImage& image, int depth); private: bool CopyFromIconOrCursor(const wxGDIImage& rIcon); -- 2.45.2