+#if defined(__WXGTK20__) && wxUSE_IMAGE
+ if (mitem->GetBitmap().Ok())
+ {
+ item_type = "<ImageItem>";
+ // GTK2's image factory know about image items, but they need to
+ // get a GdkPixbuf structure, which we need to create on the fly.
+ // This Pixbuf structure needs to be static so we create it and
+ // just make it a memory leak...
+ wxImage image( mitem->GetBitmap().ConvertToImage() );
+ size_t size = 4 + // magic
+ 20 + // header
+ image.GetHeight() * image.GetWidth() * 4; // RGBA
+
+ unsigned char *dest = new unsigned char[size];
+ entry.extra_data = dest;
+
+ unsigned char *source = image.GetData();
+ bool has_mask = image.HasMask();
+ unsigned char mask_r = image.GetMaskRed();
+ unsigned char mask_b = image.GetMaskBlue();
+ unsigned char mask_g = image.GetMaskGreen();
+ wxUint32 tmp;
+
+ // Magic
+ *dest = 'G'; dest++; *dest = 'd'; dest++; *dest = 'k'; dest++; *dest = 'P'; dest++;
+ // Data size
+ tmp = size;
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+ // Pixdata type
+ *dest = 1; dest++; *dest = 1; dest++; *dest = 0; dest++; *dest = 2; dest++;
+ // Rowstride
+ tmp = image.GetWidth()*4;
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+ // Width
+ tmp = image.GetWidth();
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+ // Height
+ tmp = image.GetHeight();
+ *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++;
+
+ for (int i = 0; i < image.GetWidth()*image.GetHeight(); i++)
+ {
+ unsigned char r = *source; source++;
+ unsigned char g = *source; source++;
+ unsigned char b = *source; source++;
+ *dest = r; dest++;
+ *dest = g; dest++;
+ *dest = b; dest++;
+ if (has_mask && (r == mask_r) && (g == mask_g) && (b == mask_b))
+ *dest = 0;
+ else
+ *dest = 255;
+ dest++;
+ }
+ break;
+ }
+#endif // GTK 2.0+