+#if wxUSE_XPM_IN_MSW
+
+static void XpmToBitmap(wxBitmap *bitmap,
+ const XImage *ximage,
+ const XpmAttributes& xpmAttr)
+{
+ wxBitmapRefData *refData = bitmap->GetBitmapData();
+ refData->m_hBitmap = (WXHBITMAP)ximage->bitmap;
+
+ // first set the bitmap width, height, depth...
+ BITMAP bm;
+ if ( !::GetObject(GetHbitmapOf(*bitmap), sizeof(bm), (LPSTR) & bm) )
+ {
+ wxLogLastError("GetObject(bitmap)");
+ }
+
+ refData->m_width = bm.bmWidth;
+ refData->m_height = bm.bmHeight;
+ refData->m_depth = bm.bmPlanes * bm.bmBitsPixel;
+ refData->m_numColors = xpmAttr.npixels;
+
+ // next get the mask, if any
+ if ( xpmAttr.mask_pixel != XpmUndefPixel )
+ {
+ int red, green, blue;
+ const char *clrString = xpmAttr.colorTable[xpmAttr.mask_pixel].c_color;
+ if ( strcmp(clrString, "None") == 0 )
+ {
+ // TODO what to do here??
+ red = green = 0;
+ blue = 1;
+ }
+ else
+ {
+ sscanf(clrString, "#%02x%02x%02x", &red, &green, &blue);
+ }
+
+ wxMask *mask = new wxMask(*bitmap, wxColour(red, green, blue));
+ bitmap->SetMask(mask);
+ }
+}
+
+#endif // wxUSE_XPM_IN_MSW
+