From c2f8c2b245959f612f0ebac31ab8d80bef6ea9e2 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Thu, 8 Aug 2013 05:43:24 +0000 Subject: [PATCH] Try native method first in LoadFile() and SaveFile() closes #15394 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74645 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/bitmap.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index f5002ef..d7f1334 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -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 -- 2.7.4