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:
@@ -1047,11 +1047,6 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
|
|||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), false, wxT("invalid bitmap") );
|
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;
|
const char* type_name = NULL;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
@@ -1061,25 +1056,37 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett
|
|||||||
case wxBITMAP_TYPE_PNG: type_name = "png"; break;
|
case wxBITMAP_TYPE_PNG: type_name = "png"; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return type_name &&
|
if (type_name &&
|
||||||
gdk_pixbuf_save(GetPixbuf(), wxGTK_CONV_FN(name), type_name, NULL, NULL);
|
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 )
|
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
|
#if wxUSE_IMAGE
|
||||||
wxImage image;
|
wxImage image;
|
||||||
if (image.LoadFile(name, type) && image.IsOk())
|
if (image.LoadFile(name, type) && image.IsOk())
|
||||||
*this = wxBitmap(image);
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
wxUnusedVar(type); // The type is detected automatically by GDK.
|
*this = wxBitmap(image);
|
||||||
|
return true;
|
||||||
*this = wxBitmap(gdk_pixbuf_new_from_file(wxGTK_CONV_FN(name), NULL));
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
return IsOk();
|
wxUnusedVar(type);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_PALETTE
|
#if wxUSE_PALETTE
|
||||||
|
Reference in New Issue
Block a user