X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2d13e22fbfbe631e5ecf037e8afdc9c2cd58418c..11716cbe14313011016472f56edb51c55aabe852:/src/gtk/bitmap.cpp?ds=inline diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 743e99c18a..9a730d8534 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -21,6 +21,7 @@ #include "wx/rawbmp.h" #include "wx/gtk/private/object.h" +#include "wx/gtk/private.h" #include @@ -309,6 +310,18 @@ wxBitmap::wxBitmap(const char* const* bits) } } +wxBitmap::wxBitmap(GdkPixbuf* pixbuf) +{ + if (pixbuf) + { + wxBitmapRefData* bmpData = new wxBitmapRefData( + gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), + gdk_pixbuf_get_n_channels(pixbuf) * 8); + m_refData = bmpData; + bmpData->m_pixbuf = pixbuf; + } +} + wxBitmap::~wxBitmap() { } @@ -665,7 +678,7 @@ bool wxBitmap::SaveFile( const wxString &name, wxBitmapType type, const wxPalett default: break; } return type_name && - gdk_pixbuf_save(GetPixbuf(), name.fn_str(), type_name, NULL, NULL); + gdk_pixbuf_save(GetPixbuf(), wxGTK_CONV_FN(name), type_name, NULL, NULL); } bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type ) @@ -679,10 +692,7 @@ bool wxBitmap::LoadFile( const wxString &name, wxBitmapType type ) { wxUnusedVar(type); // The type is detected automatically by GDK. - UnRef(); - GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(name.fn_str(), NULL); - if (pixbuf) - SetPixbuf(pixbuf); + *this = wxBitmap(gdk_pixbuf_new_from_file(wxGTK_CONV_FN(name), NULL)); } return IsOk(); @@ -802,22 +812,6 @@ bool wxBitmap::HasPixbuf() const return M_BMPDATA->m_pixbuf != NULL; } -void wxBitmap::SetPixbuf(GdkPixbuf* pixbuf) -{ - UnRef(); - - if (!pixbuf) - return; - - int depth = -1; - if (gdk_pixbuf_get_has_alpha(pixbuf)) - depth = 32; - m_refData = new wxBitmapRefData( - gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), depth); - - M_BMPDATA->m_pixbuf = pixbuf; -} - void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep) { if (keep == Pixmap && HasPixbuf())