+ gdk_gc_unref( gc );
+ return true;
+ }
+
+ // Create picture image
+
+ GdkImage *data_image =
+ gdk_image_new( GDK_IMAGE_FASTEST, visual, width, height );
+
+ // Create mask image
+
+ GdkImage *mask_image = (GdkImage*) NULL;
+
+ if (image.HasMask())
+ {
+ unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
+
+ mask_image = gdk_image_new_bitmap( visual, mask_data, width, height );
+
+ wxMask *mask = new wxMask();
+ mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 );
+
+ SetMask( mask );
+ }
+
+ // Render
+
+ enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR };
+ byte_order b_o = RGB;
+
+ if (bpp > 8)
+ {
+ 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 = RBG;
+ 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->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR;
+ }
+
+ 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++)