]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/bitmap.cpp
Added wxRichTextXMLHandler::RegisterNodeName so custom content classes can be added...
[wxWidgets.git] / src / gtk / bitmap.cpp
index 743e99c18a443ca1ea5b30997e6a1b912f4758d4..9a730d853426f5968d1f87fd3b03d48a34df0c2b 100644 (file)
@@ -21,6 +21,7 @@
 #include "wx/rawbmp.h"
 
 #include "wx/gtk/private/object.h"
+#include "wx/gtk/private.h"
 
 #include <gtk/gtk.h>
 
@@ -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())