-
- if ((r == 255) && (b == 255) && (g == 255))
- gdk_image_put_pixel( data_image, x, y, 0 );
-
- } // for
- } // for
-
- // Blit picture
-
- gdk_draw_image( GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height );
-
- g_object_unref (data_image);
- g_object_unref (data_gc);
-
- // Blit mask
-
- if (mask_image != NULL)
- {
- gdk_draw_image( GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height );
-
- g_object_unref (mask_image);
- g_object_unref (mask_gc);
- }
-
- return true;
-}
-
-// conversion to colour bitmap:
-bool wxBitmap::CreateFromImageAsPixmap(const wxImage& img)
-{
- // convert alpha channel to mask, if it is present:
- wxImage image(img);
- image.ConvertAlphaToMask();
-
- int width = image.GetWidth();
- int height = image.GetHeight();
-
- SetHeight( height );
- SetWidth( width );
-
- SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) );
-
- GdkVisual *visual = wxTheApp->GetGdkVisual();
-
- int bpp = visual->depth;
-
- SetDepth( bpp );
-
- GdkGC *gc = gdk_gc_new( GetPixmap() );
-
- gdk_draw_rgb_image( GetPixmap(),
- gc,
- 0, 0,
- width, height,
- GDK_RGB_DITHER_NONE,
- image.GetData(),
- width*3 );
-
- g_object_unref (gc);
-
- // Create mask image
-
- if (!image.HasMask())
- return true;
-
- wxMask *mask = new wxMask();
- mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
- GdkGC* mask_gc = gdk_gc_new(mask->m_bitmap);
- GdkColor color;
- color.pixel = 1;
- gdk_gc_set_foreground(mask_gc, &color);
- gdk_draw_rectangle(mask->m_bitmap, mask_gc, true, 0, 0, width, height);
- GdkImage* mask_image = gdk_drawable_get_image(mask->m_bitmap, 0, 0, width, height);
-
- SetMask( mask );
-
- int r_mask = image.GetMaskRed();
- int g_mask = image.GetMaskGreen();
- int b_mask = image.GetMaskBlue();
-
- unsigned char* data = image.GetData();
-
- int index = 0;
- for (int y = 0; y < height; y++)
- {
- for (int x = 0; x < width; x++)