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
This commit is contained in:
parent
07fb285c52
commit
c2f8c2b245
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user