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
This commit is contained in:
Václav Slavík
2001-04-04 23:15:36 +00:00
parent b5f01ae00e
commit fd85921189
7 changed files with 48 additions and 0 deletions

View File

@@ -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;
@@ -80,6 +82,8 @@ public:
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)

View File

@@ -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;
@@ -80,6 +82,8 @@ public:
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)

View File

@@ -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 );
@@ -138,6 +141,9 @@ public:
void Replace( unsigned char r1, unsigned char g1, unsigned char b1,
unsigned char r2, unsigned char g2, unsigned char b2 );
// convert to monochrome image (<r,g,b> 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 );
unsigned char GetRed( int x, int y ) const;
@@ -229,6 +235,7 @@ private:
extern void WXDLLEXPORT wxInitAllImageHandlers();
WXDLLEXPORT_DATA(extern wxImage) wxNullImage;
//-----------------------------------------------------------------------------
// wxImage handlers

View File

@@ -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,8 +153,14 @@ 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;

View File

@@ -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);
@@ -165,6 +170,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); }
int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 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

View File

@@ -28,6 +28,7 @@ class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxMask;
class WXDLLEXPORT wxCursor;
class WXDLLEXPORT wxControl;
class WXDLLEXPORT wxImage;
// ----------------------------------------------------------------------------
// Bitmap data
@@ -90,6 +91,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!
wxBitmap(const wxIcon& icon) { Init(); CopyFromIcon(icon); }
@@ -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__

View File

@@ -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);