if (!image.Ok()) return FALSE;
 
     m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
     if (!image.Ok()) return FALSE;
 
     m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 );
     wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
     wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
 
     wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
     wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
 
         SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
 
         SetDepth( 1 );
         SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) );
 
         SetDepth( 1 );
 
         SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
 
 
         SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
 
-        // Retrieve depth, using XVisualInfo from app, if set
-        GdkVisual *visual;
-        if (wxTheApp->m_glVisualInfo)
-        {
-            visual = gdkx_visual_get( ((XVisualInfo *) wxTheApp->m_glVisualInfo)->visualid );
-        }
-        else
-        {
-            visual = gdk_window_get_visual( wxGetRootWindow()->window );
-        }
-        wxASSERT( visual );
+        GdkVisual *visual = wxTheApp->GetGdkVisual();
         if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
         if (bpp < 8) bpp = 8;
 
         // We handle 8-bit bitmaps ourselves using the colour cube, 12-bit 
         // visuals are not supported by GDK so we do these ourselves, too.
         // 15-bit and 16-bit should actually work and 24-bit certainly does.
         if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
         if (bpp < 8) bpp = 8;
 
         // We handle 8-bit bitmaps ourselves using the colour cube, 12-bit 
         // visuals are not supported by GDK so we do these ourselves, too.
         // 15-bit and 16-bit should actually work and 24-bit certainly does.
             else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask))   b_o = BRG;
             else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
             else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask))   b_o = GRB;
             else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask))   b_o = BRG;
             else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
             else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask))   b_o = GRB;
-                            case RGB: pixel = ((r & 0xf8) << 7) | ((g & 0xfc) << 2) | ((b & 0xf8) >> 3); break;
-                            case RBG: pixel = ((r & 0xf8) << 7) | ((b & 0xfc) << 2) | ((g & 0xf8) >> 3); break;
-                            case GRB: pixel = ((g & 0xf8) << 7) | ((r & 0xfc) << 2) | ((b & 0xf8) >> 3); break;
-                            case GBR: pixel = ((g & 0xf8) << 7) | ((b & 0xfc) << 2) | ((r & 0xf8) >> 3); break;
-                            case BRG: pixel = ((b & 0xf8) << 7) | ((r & 0xfc) << 2) | ((g & 0xf8) >> 3); break;
-                            case BGR: pixel = ((b & 0xf8) << 7) | ((g & 0xfc) << 2) | ((r & 0xf8) >> 3); break;
+                            case RGB: pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); break;
+                            case RBG: pixel = ((r & 0xf8) << 8) | ((b & 0xfc) << 3) | ((g & 0xf8) >> 3); break;
+                            case GRB: pixel = ((g & 0xf8) << 8) | ((r & 0xfc) << 3) | ((b & 0xf8) >> 3); break;
+                            case GBR: pixel = ((g & 0xf8) << 8) | ((b & 0xfc) << 3) | ((r & 0xf8) >> 3); break;
+                            case BRG: pixel = ((b & 0xf8) << 8) | ((r & 0xfc) << 3) | ((g & 0xf8) >> 3); break;
+                            case BGR: pixel = ((b & 0xf8) << 8) | ((g & 0xfc) << 3) | ((r & 0xf8) >> 3); break;
                         }
                         gdk_image_put_pixel( data_image, x, y, pixel );
                         break;
                         }
                         gdk_image_put_pixel( data_image, x, y, pixel );
                         break;
 
     image.Create( GetWidth(), GetHeight() );
     char unsigned *data = image.GetData();
 
     image.Create( GetWidth(), GetHeight() );
     char unsigned *data = image.GetData();
         bpp = visual->depth;
         if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
         red_shift_right = visual->red_shift;
         bpp = visual->depth;
         if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
         red_shift_right = visual->red_shift;