X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0bafad0cf468cdd3b035ec8eb33e30a4e93eee42..4004f41e3ce1655f9fa05c55a697ac0f8677c23a:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index 1813a6fce0..58dec0c3b6 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1309,12 +1309,15 @@ wxBitmap wxImage::ConvertToMonoBitmap( unsigned char red, unsigned char green, u bitmap.SetDepth( 1 ); + GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); + wxASSERT( visual ); + // Create picture image unsigned char *data_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); GdkImage *data_image = - gdk_image_new_bitmap( gdk_visual_get_system(), data_data, width, height ); + gdk_image_new_bitmap( visual, data_data, width, height ); // Create mask image @@ -1324,7 +1327,7 @@ wxBitmap wxImage::ConvertToMonoBitmap( unsigned char red, unsigned char green, u { unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); + mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); wxMask *mask = new wxMask(); mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); @@ -1405,10 +1408,11 @@ wxBitmap wxImage::ConvertToBitmap() const bitmap.SetPixmap( gdk_pixmap_new( wxRootWindow->window, width, height, -1 ) ); - // Retrieve depth + // Retrieve depth - GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); - if (visual == NULL) visual = gdk_visual_get_system(); + GdkVisual *visual = gdk_window_get_visual( wxRootWindow->window ); + wxASSERT( visual ); + int bpp = visual->depth; bitmap.SetDepth( bpp ); @@ -1448,7 +1452,7 @@ wxBitmap wxImage::ConvertToBitmap() const // Create picture image GdkImage *data_image = - gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(), width, height ); + gdk_image_new( GDK_IMAGE_FASTEST, visual, width, height ); // Create mask image @@ -1458,7 +1462,7 @@ wxBitmap wxImage::ConvertToBitmap() const { unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height ); + mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); wxMask *mask = new wxMask(); mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 ); @@ -1473,7 +1477,6 @@ wxBitmap wxImage::ConvertToBitmap() const if (bpp >= 24) { - GdkVisual *visual = gdk_visual_get_system(); if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB; else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB; else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;