X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ee437b7e1d7111514b40b3588ad8f2a8d8b45f78..169dc97542bcf418ad8244bdba45014e2337d9a6:/src/mgl/bitmap.cpp diff --git a/src/mgl/bitmap.cpp b/src/mgl/bitmap.cpp index ad2e0199a1..3c717d4fe9 100644 --- a/src/mgl/bitmap.cpp +++ b/src/mgl/bitmap.cpp @@ -58,12 +58,13 @@ static pixel_format_t gs_pixel_format_wxImage = {0xFF,0x00,0, 0xFF,0x08,0, 0xFF,0x10,0, 0x00,0x00,0}; // RGB 24bpp for wxImage //----------------------------------------------------------------------------- -// wxBitmap +// wxBitmapRefData //----------------------------------------------------------------------------- class wxBitmapRefData: public wxGDIRefData { public: + wxBitmapRefData(); wxBitmapRefData(int width, int height, int bpp); wxBitmapRefData(const wxBitmapRefData& data); virtual ~wxBitmapRefData(); @@ -78,11 +79,15 @@ public: bitmap_t *m_bitmap; private: - void DoCreateBitmap(); + void DoCreateBitmap(int width, int height, int depth); }; -void wxBitmapRefData::DoCreateBitmap() +void wxBitmapRefData::DoCreateBitmap(int width, int height, int depth) { + m_width = width; + m_height = height; + m_bpp = depth; + pixel_format_t pf_dummy; pixel_format_t *pf; int mglDepth = depth; @@ -122,28 +127,32 @@ void wxBitmapRefData::DoCreateBitmap() m_bitmap = MyMGL_createBitmap(width, height, mglDepth, pf); } -wxBitmapRefData::wxBitmapRefData(int width, int height, int bpp) +wxBitmapRefData::wxBitmapRefData() { - m_width = width; - m_height = height; - m_bpp = bpp; + m_width = + m_height = + m_bpp = 0; m_palette = NULL; m_mask = NULL; - DoCreateBitmap(); + m_bitmap = NULL; +} + +wxBitmapRefData::wxBitmapRefData(int width, int height, int bpp) +{ + DoCreateBitmap(width, height, bpp); + + m_palette = NULL; + m_mask = NULL; } wxBitmapRefData::wxBitmapRefData(const wxBitmapRefData& data) { - m_width = data.m_width; - m_height = data.m_height; - m_bpp = data.m_bpp; + DoCreateBitmap(data.m_width, data.m_height, data.m_bpp); m_palette = NULL; // FIXME: should copy m_mask = NULL; // FIXME: should copy - - DoCreateBitmap(); } wxBitmapRefData::~wxBitmapRefData() @@ -154,18 +163,15 @@ wxBitmapRefData::~wxBitmapRefData() delete m_palette; } + +//----------------------------------------------------------------------------- +// wxBitmap //----------------------------------------------------------------------------- #define M_BMPDATA ((wxBitmapRefData *)m_refData) IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxBitmapBase) -wxBitmap::wxBitmap(int width, int height, int depth) -{ - Create(width, height, depth); -} - - wxGDIRefData *wxBitmap::CreateGDIRefData() const { return new wxBitmapRefData; @@ -173,7 +179,7 @@ wxGDIRefData *wxBitmap::CreateGDIRefData() const wxGDIRefData *wxBitmap::CloneGDIRefData(const wxGDIRefData *data) const { - return new wxBitmapRefData(*wx_static_cast(const wxBitmapRefData *, data)); + return new wxBitmapRefData(*static_cast(data)); } bool wxBitmap::Create(int width, int height, int depth) @@ -314,7 +320,7 @@ int wxBitmap::GetDepth() const wxMask *wxBitmap::GetMask() const { - wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") ); + wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") ); return M_BMPDATA->m_mask; }