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") )
m_refData = new wxBitmapRefData();
// ------
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
m_refData = new wxBitmapRefData();
// ------
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();
// 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.
// 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;
gdk_image_put_pixel( data_image, x, y, pixel );
gdk_image_put_pixel( data_image, x, y, pixel );
- 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;
+ // the colour used as transparent one in wxImage and the one it is replaced
+ // with when it really occurs in the bitmap
+ static const int MASK_RED = 1;
+ static const int MASK_GREEN = 2;
+ static const int MASK_BLUE = 3;
+ static const int MASK_BLUE_REPLACEMENT = 2;
+
red_shift_right = visual->red_shift;
red_shift_left = 8-visual->red_prec;
green_shift_right = visual->green_shift;
red_shift_right = visual->red_shift;
red_shift_left = 8-visual->red_prec;
green_shift_right = visual->green_shift;
- data[pos] = 16;
- data[pos+1] = 16;
- data[pos+2] = 16;
+ data[pos] = MASK_RED;
+ data[pos+1] = MASK_GREEN;
+ data[pos+2] = MASK_BLUE;
+ }
+ else if ( data[pos] == MASK_RED &&
+ data[pos+1] == MASK_GREEN &&
+ data[pos+2] == MASK_BLUE )
+ {
+ data[pos+2] = MASK_BLUE_REPLACEMENT;