]> git.saurik.com Git - wxWidgets.git/commitdiff
Allow create of 24-bit bitmap, use Pixbuf when not a 24-bit visual
authorRobert Roebling <robert@roebling.de>
Sat, 18 Oct 2008 14:32:56 +0000 (14:32 +0000)
committerRobert Roebling <robert@roebling.de>
Sat, 18 Oct 2008 14:32:56 +0000 (14:32 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56421 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/bitmap.cpp

index 88d5a0d6d8d6a0ce34f3372255218fb2d5a48304..ede32fc4430f8c8a8e4cef127580d3da1467a1db 100644 (file)
@@ -280,21 +280,26 @@ bool wxBitmap::Create( int width, int height, int depth )
         return false;
     }
 
+    const GdkVisual* visual = wxTheApp->GetGdkVisual();
+    
     if (depth == 32)
     {
         SetPixbuf(gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, width, height), 32);
+    } else
+    if (depth == 24)
+    {
+        if (visual->depth == depth)
+            SetPixmap(gdk_pixmap_new(wxGetRootWindow()->window, width, height, depth));
+        else
+            SetPixbuf(gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, width, height), 24);
     }
     else
     {
         if (depth != 1)
         {
-            const GdkVisual* visual = wxTheApp->GetGdkVisual();
             if (depth == -1)
                 depth = visual->depth;
-
-            wxCHECK_MSG(depth == visual->depth, false, wxT("invalid bitmap depth"));
         }
-
         SetPixmap(gdk_pixmap_new(wxGetRootWindow()->window, width, height, depth));
     }
 
@@ -807,6 +812,7 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
 
     if (M_BMPDATA->m_pixbuf == NULL)
     {
+     
         int width = GetWidth();
         int height = GetHeight();
 
@@ -816,7 +822,6 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
         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)
         {
@@ -896,6 +901,7 @@ 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 && ((bpp == 24 && !hasAlpha) || (bpp == 32 && hasAlpha)) )
     {