]> git.saurik.com Git - wxWidgets.git/commitdiff
Try native method first in LoadFile() and SaveFile()
authorPaul Cornett <paulcor@bullseye.com>
Thu, 8 Aug 2013 05:43:24 +0000 (05:43 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Thu, 8 Aug 2013 05:43:24 +0000 (05:43 +0000)
closes #15394

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74645 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/bitmap.cpp

index f5002efd32653744160063a245789d38603348c7..d7f13343282746c5da876d2b014ec9a2feba6b6a 100644 (file)
@@ -1047,11 +1047,6 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
 {
     wxCHECK_MSG( IsOk(), false, wxT("invalid bitmap") );
 
-#if wxUSE_IMAGE
-    wxImage image = ConvertToImage();
-    if (image.IsOk() && image.SaveFile(name, type))
-        return true;
-#endif
     const char* type_name = NULL;
     switch (type)
     {
@@ -1061,25 +1056,37 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
         case wxBITMAP_TYPE_PNG:  type_name = "png";  break;
         default: break;
     }
-    return type_name &&
-        gdk_pixbuf_save(GetPixbuf(), wxGTK_CONV_FN(name), type_name, NULL, NULL);
+    if (type_name &&
+        gdk_pixbuf_save(GetPixbuf(), wxGTK_CONV_FN(name), type_name, NULL, NULL))
+    {
+        return true;
+    }
+#if wxUSE_IMAGE
+    return ConvertToImage().SaveFile(name, type);
+#else
+    return false;
+#endif
 }
 
 bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type )
 {
+    GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(wxGTK_CONV_FN(name), NULL);
+    if (pixbuf)
+    {
+        *this = wxBitmap(pixbuf);
+        return true;
+    }
 #if wxUSE_IMAGE
     wxImage image;
     if (image.LoadFile(name, type) && image.IsOk())
-        *this = wxBitmap(image);
-    else
-#endif
     {
-        wxUnusedVar(type); // The type is detected automatically by GDK.
-
-        *this = wxBitmap(gdk_pixbuf_new_from_file(wxGTK_CONV_FN(name), NULL));
+        *this = wxBitmap(image);
+        return true;
     }
-
-    return IsOk();
+#else
+    wxUnusedVar(type);
+#endif
+    return false;
 }
 
 #if wxUSE_PALETTE