X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fec19ea9ff590f401ad17b1e2109b1e95d2f5e91..a27d279f9dda39fea578ad29a61e8eb23548a00f:/src/os2/bitmap.cpp diff --git a/src/os2/bitmap.cpp b/src/os2/bitmap.cpp index eb52b51de1..285a736eda 100644 --- a/src/os2/bitmap.cpp +++ b/src/os2/bitmap.cpp @@ -33,6 +33,7 @@ //#include "wx/msw/dib.h" #include "wx/image.h" +#include "wx/xpmdecod.h" // ---------------------------------------------------------------------------- // macros @@ -211,37 +212,6 @@ wxBitmap::wxBitmap( SetHBITMAP((WXHBITMAP)hBmp); } // end of wxBitmap::wxBitmap -// -// Create from XPM data -// -wxBitmap::wxBitmap( - char** ppData -) -{ - Init(); - - (void)Create( (void *)ppData - ,wxBITMAP_TYPE_XPM_DATA - ,0 - ,0 - ,0 - ); -} // end of wxBitmap::wxBitmap - -wxBitmap::wxBitmap( - const char** ppData -) -{ - Init(); - - (void)Create( (void *)ppData - ,wxBITMAP_TYPE_XPM_DATA - ,0 - ,0 - ,0 - ); -} // end of wxBitmap::wxBitmap - wxBitmap::wxBitmap( int nW , int nH @@ -361,6 +331,27 @@ bool wxBitmap::Create( return Ok(); } // end of wxBitmap::Create +bool wxBitmap::CreateFromXpm( + const char** ppData +) +{ +#if wxUSE_IMAGE && wxUSE_XPM + Init(); + + wxCHECK_MSG(ppData != NULL, FALSE, wxT("invalid bitmap data")) + + wxXPMDecoder vDecoder; + wxImage vImg = vDecoder.ReadData(ppData); + + wxCHECK_MSG(vImg.Ok(), FALSE, wxT("invalid bitmap data")) + + *this = wxBitmap(vImg); + return TRUE; +#else + return FALSE; +#endif +} // end of wxBitmap::CreateFromXpm + bool wxBitmap::LoadFile( const wxString& rFilename , long lType @@ -393,7 +384,7 @@ bool wxBitmap::LoadFile( if (!vImage.LoadFile(rFilename, lType) || !vImage.Ok() ) return(FALSE); - *this = vImage.ConvertToBitmap(); + *this = wxBitmap(vImage); return(TRUE); } @@ -453,7 +444,7 @@ bool wxBitmap::SaveFile( else { // FIXME what about palette? shouldn't we use it? - wxImage vImage(*this); + wxImage vImage = ConvertToImage(); if (!vImage.Ok()) return(FALSE); @@ -671,7 +662,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) wxImage wxBitmap::ConvertToImage() const { wxImage image; - + wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); // create an wxImage object