+}
+
+void wxBitmap::DestroyImage(void)
+{
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid bitmap" );
+ return;
+ }
+
+ if (M_BMPDATA->m_image)
+ {
+ gdk_imlib_destroy_image( M_BMPDATA->m_image );
+ M_BMPDATA->m_image = (GdkImlibImage *) NULL;
+ }
+}
+
+void wxBitmap::RecreateImage(void)
+{
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid bitmap" );
+ return;
+ }
+
+#ifdef wxUSE_GDK_IMLIB
+
+ DestroyImage();
+
+ wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "invalid bitmap" );
+
+ long size = (long)(M_BMPDATA->m_width)*(long)(M_BMPDATA->m_height)*(long)3;
+ unsigned char *data = new unsigned char[size];
+ for (long i = 0; i < size; i++) data[i] = 100;
+
+ GdkImage *image = gdk_image_get( M_BMPDATA->m_pixmap, 0, 0, M_BMPDATA->m_width, M_BMPDATA->m_height );
+
+ long pos = 0;
+ for (int j = 0; j < M_BMPDATA->m_height; j++)
+ {
+ for (int i = 0; i < M_BMPDATA->m_width; i++)
+ {
+ XColor xcol;
+ xcol.pixel = gdk_image_get_pixel( image, i, j );
+ Colormap cm = ((GdkColormapPrivate*)gdk_imlib_get_colormap())->xcolormap;
+ XQueryColor( gdk_display, cm, &xcol );
+
+ data[pos] = xcol.red;
+ data[pos+1] = xcol.green;
+ data[pos+2] = xcol.blue;
+ pos += 3;
+ }
+ }
+
+ wxCHECK_RET( M_BMPDATA->m_pixmap != NULL, "invalid bitmap" );
+
+ M_BMPDATA->m_image = gdk_imlib_create_image_from_data(
+ data, (unsigned char*)NULL, M_BMPDATA->m_width, M_BMPDATA->m_height );
+
+ delete[] data;
+
+ gdk_image_destroy( image );
+
+ Render();
+
+#else
+
+ wxFAIL_MSG( "wxBitmap::RecreateImage not implemented without GdkImlib" );