]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/bitmap.cpp
New radio item menu stuff
[wxWidgets.git] / src / os2 / bitmap.cpp
index eb52b51de1fdc61911bc55e8d99cc3d81f239e4b..285a736eda2e9345453b4de5e3f9918f0b655977 100644 (file)
@@ -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