- /* for following SetPixel */
- /* fill the XImage struct 'by hand' */
- wxBitmapRefData *refData = bitmap->GetBitmapData();
- ximage.width = refData->m_width;
- ximage.height = refData->m_height;
- ximage.depth = refData->m_depth;
- ximage.bitmap = (HBITMAP)refData->m_hBitmap;
- int errorStatus = XpmWriteFileFromImage(&dc, wxMBSTRINGCAST name.fn_str(),
- &ximage, (XImage *) NULL,
- (XpmAttributes *) NULL);
-
- if (dc)
- DeleteDC(dc);
-
- if (errorStatus == XpmSuccess)
- return TRUE; /* no error */
- else
- return FALSE;
- } else return FALSE;
- } else return FALSE;
-#else
+ /* Strangely enough, the MSW version of xpmlib is not
+ * coherent with itself regarding masks; we have to invert
+ * the mask we get when loading, but we still must pass it
+ * 'as is' when saving...
+ */
+ xmask.bitmap = (HBITMAP) refData->m_bitmapMask->GetMaskBitmap();
+ xmask.width = refData->m_width;
+ xmask.height = refData->m_height;
+ xmask.depth = 1;
+ }
+
+ int errorStatus = XpmWriteFileFromImage(
+ &dc,
+ wxMBSTRINGCAST name.fn_str(),
+ &ximage,
+ (hasmask? &xmask : (XImage *)NULL),
+ (XpmAttributes *) NULL);
+
+ DeleteDC(dc);
+
+ return (errorStatus == XpmSuccess);
+ }
+#endif // !wxUSE_XPM_IN_MSW
+