+    return M_BMPDATA->m_pixmap != NULL;
+}
+
+GdkPixbuf *wxBitmap::GetPixbuf() const
+{
+    wxCHECK_MSG( Ok(), NULL, wxT("invalid bitmap") );
+
+    if (M_BMPDATA->m_pixbuf == NULL)
+    {
+        int width = GetWidth();
+        int height = GetHeight();
+
+        GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
+                                           GetMask() != NULL,
+                                           8, width, height);
+        M_BMPDATA->m_pixbuf = pixbuf;
+        gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL,
+                                     0, 0, 0, 0, width, height);
+
+        // apply the mask to created pixbuf:
+        if (M_BMPDATA->m_pixbuf && M_BMPDATA->m_mask)
+        {
+            GdkPixbuf *pmask =
+                gdk_pixbuf_get_from_drawable(NULL,
+                                             M_BMPDATA->m_mask->GetBitmap(),
+                                             NULL,
+                                             0, 0, 0, 0, width, height);
+            if (pmask)
+            {
+                guchar *bmp = gdk_pixbuf_get_pixels(pixbuf);
+                guchar *mask = gdk_pixbuf_get_pixels(pmask);
+                int bmprowinc = gdk_pixbuf_get_rowstride(pixbuf) - 4 * width;
+                int maskrowinc = gdk_pixbuf_get_rowstride(pmask) - 3 * width;
+
+                for (int y = 0; y < height;
+                     y++, bmp += bmprowinc, mask += maskrowinc)
+                {
+                    for (int x = 0; x < width; x++, bmp += 4, mask += 3)
+                    {
+                        if (mask[0] == 0 /*black pixel*/)
+                            bmp[3] = 0;
+                    }
+                }
+
+                g_object_unref (pmask);
+            }
+        }
+    }
+
+    return M_BMPDATA->m_pixbuf;
+}
+
+bool wxBitmap::HasPixbuf() const
+{
+    wxCHECK_MSG( Ok(), false, wxT("invalid bitmap") );
+
+    return M_BMPDATA->m_pixbuf != NULL;
+}
+
+void wxBitmap::SetPixbuf(GdkPixbuf* pixbuf, int depth)
+{
+    if (!m_refData)
+        m_refData = new wxBitmapRefData;
+
+    // AllocExclusive should not be needed for this internal function
+    wxASSERT(m_refData->GetRefCount() == 1);
+    wxASSERT(M_BMPDATA->m_pixbuf == NULL);
+    M_BMPDATA->m_pixbuf = pixbuf;
+    M_BMPDATA->m_width = gdk_pixbuf_get_width(pixbuf);
+    M_BMPDATA->m_height = gdk_pixbuf_get_height(pixbuf);
+    // if depth specified
+    if (depth != 0)
+        M_BMPDATA->m_bpp = depth;
+    else if (M_BMPDATA->m_bpp == 0)
+        // use something reasonable
+        M_BMPDATA->m_bpp = wxTheApp->GetGdkVisual()->depth;
+    PurgeOtherRepresentations(Pixbuf);
+}
+
+void wxBitmap::PurgeOtherRepresentations(wxBitmap::Representation keep)
+{
+    if (keep == Pixmap && HasPixbuf())
+    {
+        g_object_unref (M_BMPDATA->m_pixbuf);
+        M_BMPDATA->m_pixbuf = NULL;
+    }
+    if (keep == Pixbuf && HasPixmap())
+    {
+        g_object_unref (M_BMPDATA->m_pixmap);
+        M_BMPDATA->m_pixmap = NULL;
+    }
+}
+
+void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
+{
+    void* bits = NULL;
+    GdkPixbuf *pixbuf = GetPixbuf();
+    const bool hasAlpha = HasAlpha();
+    // allow access if bpp is valid and matches existence of alpha
+    if (pixbuf != NULL && (
+        bpp == 24 && !hasAlpha ||
+        bpp == 32 && hasAlpha))
+    {
+        data.m_height = gdk_pixbuf_get_height( pixbuf );
+        data.m_width = gdk_pixbuf_get_width( pixbuf );
+        data.m_stride = gdk_pixbuf_get_rowstride( pixbuf );
+        bits = gdk_pixbuf_get_pixels(pixbuf);
+    }
+    return bits;
+}
+
+void wxBitmap::UngetRawData(wxPixelDataBase& WXUNUSED(data))
+{
+}
+
+bool wxBitmap::HasAlpha() const
+{
+    return m_refData != NULL && M_BMPDATA->m_pixbuf != NULL &&
+        gdk_pixbuf_get_has_alpha(M_BMPDATA->m_pixbuf);