]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/image.cpp
Recent commits added new variables for length when there is already one available...
[wxWidgets.git] / src / common / image.cpp
index 204c4b665740e2ed47e4ea436eff91a85d85fdbb..627bcadcf2bfa83415e41e4421cede5e506562ab 100644 (file)
 #include "wx/utils.h"
 #include "wx/math.h"
 
+#if wxUSE_XPM
+#include "wx/xpmdecod.h"
+#endif
+
 // For memcpy
 #include <string.h>
 
@@ -159,6 +163,29 @@ wxImage::wxImage( const wxImage* image )
     if (image) Ref(*image);
 }
 
+wxImage::wxImage( const char** xpmData )
+{
+    Create(xpmData);
+}
+
+wxImage::wxImage( char** xpmData )
+{
+    Create((const char**) xpmData);
+}
+
+bool wxImage::Create( const char** xpmData )
+{
+#if wxUSE_XPM
+    UnRef();
+    
+    wxXPMDecoder decoder;
+    (*this) = decoder.ReadData(xpmData);
+    return Ok();
+#else
+    return false;
+#endif
+}
+
 bool wxImage::Create( int width, int height, bool clear )
 {
     UnRef();
@@ -1235,6 +1262,8 @@ bool wxImage::SaveFile( const wxString& filename ) const
 bool wxImage::SaveFile( const wxString& filename, int type ) const
 {
 #if wxUSE_STREAMS
+    wxCHECK_MSG( Ok(), false, wxT("invalid image") );
+
     ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename);
 
     wxFileOutputStream stream(filename);
@@ -1252,6 +1281,8 @@ bool wxImage::SaveFile( const wxString& filename, int type ) const
 bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) const
 {
 #if wxUSE_STREAMS
+    wxCHECK_MSG( Ok(), false, wxT("invalid image") );
+
     ((wxImage*)this)->SetOption(wxIMAGE_OPTION_FILENAME, filename);
 
     wxFileOutputStream stream(filename);
@@ -1401,8 +1432,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, int type ) const
     wxCHECK_MSG( Ok(), false, wxT("invalid image") );
 
     wxImageHandler *handler = FindHandler(type);
-
-    if (handler == 0)
+    if ( !handler )
     {
         wxLogWarning( _("No image handler for type %d defined."), type );
 
@@ -1417,8 +1447,7 @@ bool wxImage::SaveFile( wxOutputStream& stream, const wxString& mimetype ) const
     wxCHECK_MSG( Ok(), false, wxT("invalid image") );
 
     wxImageHandler *handler = FindHandlerMime(mimetype);
-
-    if (handler == 0)
+    if ( !handler )
     {
         wxLogWarning( _("No image handler for type %s defined."), mimetype.GetData() );