if( HasMask() )
{
hbitmap = ::CreateBitmap( (WORD)width, (WORD)bmpHeight, 1, 1, NULL );
- ::SelectObject( memdc, hbitmap);
+ HGDIOBJ hbmpOld = ::SelectObject( memdc, hbitmap);
if( numDIB == 1 ) height = bmpHeight;
else height = sizeLimit/bytePerLine;
lpDIBh->bmiHeader.biHeight = (DWORD)(-height);
wxMask *mask = new wxMask( bitmap, colour );
bitmap.SetMask( mask );
*/
+
+ ::SelectObject( memdc, hbmpOld );
}
// free allocated resources
- ::SelectObject( memdc, 0 );
::DeleteDC( memdc );
::ReleaseDC(NULL, hdc);
free(lpDIBh);
#include <gdk/gdkrgb.h>
#endif
+extern GtkWidget *wxRootWindow;
+
wxBitmap wxImage::ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue )
{
wxBitmap bitmap;
bitmap.SetHeight( height );
bitmap.SetWidth( width );
- bitmap.SetBitmap( gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ) );
+ bitmap.SetBitmap( gdk_pixmap_new( wxRootWindow->window, width, height, 1 ) );
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
{
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( (GdkWindow*)&gdk_root_parent, width, height, 1 );
+ mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 );
bitmap.SetMask( mask );
}
bitmap.SetHeight( height );
bitmap.SetWidth( width );
- bitmap.SetPixmap( gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, -1 ) );
+ 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 );
// 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
{
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( (GdkWindow*)&gdk_root_parent, width, height, 1 );
+ mask->m_bitmap = gdk_pixmap_new( wxRootWindow->window, width, height, 1 );
bitmap.SetMask( mask );
}
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;
{
GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() );
- if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
+ if (visual == NULL) visual = gdk_window_get_visual( wxRootWindow->window );
bpp = visual->depth;
if (bpp == 16) bpp = visual->red_prec + visual->green_prec + visual->blue_prec;
red_shift_right = visual->red_shift;