+// Get the bitmap
+wxBitmap wxImageList::GetBitmap(int index) const
+{
+#if wxUSE_WXDIB && wxUSE_IMAGE
+ int bmp_width = 0, bmp_height = 0;
+ GetSize(index, bmp_width, bmp_height);
+
+ wxBitmap bitmap(bmp_width, bmp_height);
+ wxMemoryDC dc;
+ dc.SelectObject(bitmap);
+
+ // draw it the first time to find a suitable mask colour
+ ((wxImageList*)this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT);
+ dc.SelectObject(wxNullBitmap);
+
+ // find the suitable mask colour
+ wxImage image = bitmap.ConvertToImage();
+ unsigned char r = 0, g = 0, b = 0;
+ image.FindFirstUnusedColour(&r, &g, &b);
+
+ // redraw whole image and bitmap in the mask colour
+ image.Create(bmp_width, bmp_height);
+ image.Replace(0, 0, 0, r, g, b);
+ bitmap = wxBitmap(image);
+
+ // redraw icon over the mask colour to actually draw it
+ dc.SelectObject(bitmap);
+ ((wxImageList*)this)->Draw(index, dc, 0, 0, wxIMAGELIST_DRAW_TRANSPARENT);
+ dc.SelectObject(wxNullBitmap);
+
+ // get the image, set the mask colour and convert back to get transparent bitmap
+ image = bitmap.ConvertToImage();
+ image.SetMaskColour(r, g, b);
+ bitmap = wxBitmap(image);
+#else
+ wxBitmap bitmap;