#if wxUSE_XPM_IN_MSW
#define FOR_MSW 1
-#include "../../contrib/wxxpm/libxpm.34b/lib/xpm34.h"
+#include "../src/xpm/xpm34.h"
#endif
#include "wx/msw/dib.h"
if (m_bitmapMask)
delete m_bitmapMask;
m_bitmapMask = NULL;
+
}
wxList wxBitmap::sm_handlers;
#if wxUSE_XPM_IN_MSW
// Create from data
-wxBitmap::wxBitmap(const char **data, wxItem *WXUNUSED(anItem))
+wxBitmap::wxBitmap(char **data, wxItem *WXUNUSED(anItem))
{
(void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
}
LPBITMAPINFO lpDib;
void *lpBits = NULL;
+/*
wxASSERT( this->GetPalette() && this->GetPalette()->Ok() && (this->GetPalette()->GetHPALETTE() != 0) );
tmpBitmap.SetPalette(this->GetPalette());
memDC.SetPalette(this->GetPalette());
hPal = (HPALETTE) this->GetPalette()->GetHPALETTE();
+*/
+ if( this->GetPalette() && this->GetPalette()->Ok() && (this->GetPalette()->GetHPALETTE() != 0) )
+ {
+ tmpBitmap.SetPalette(* this->GetPalette());
+ memDC.SelectObject(tmpBitmap);
+ memDC.SetPalette(* this->GetPalette());
+ hPal = (HPALETTE) this->GetPalette()->GetHPALETTE();
+ }
+ else
+ {
+ hPal = (HPALETTE) ::GetStockObject(DEFAULT_PALETTE);
+ wxPalette palette;
+ palette.SetHPALETTE( (WXHPALETTE)hPal );
+ tmpBitmap.SetPalette( palette );
+ memDC.SelectObject(tmpBitmap);
+ memDC.SetPalette( palette );
+ }
// set the height negative because in a DIB the order of the lines is reversed
createDIB(this->GetWidth(), -this->GetHeight(), this->GetDepth(), hPal, &lpDib);
bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
{
#if wxUSE_XPM_IN_MSW
- HDC dc = NULL;
-
- Visual *visual = NULL;
- XImage ximage;
-
- dc = CreateCompatibleDC(NULL);
- if (dc)
- {
+ HDC dc = NULL;
+
+ XImage ximage;
+
+ dc = CreateCompatibleDC(NULL);
+ if (dc)
+ {
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
- { /* for following SetPixel */
- /* fill the XImage struct 'by hand' */
- ximage.width = M_BITMAPHANDLERDATA->m_width;
- ximage.height = M_BITMAPHANDLERDATA->m_height;
- ximage.depth = M_BITMAPHANDLERDATA->m_depth;
- ximage.bitmap = (void *)M_BITMAPHANDLERDATA->m_hBitmap;
- int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name,
- &ximage, (XImage *) NULL, (XpmAttributes *) NULL);
-
- if (dc)
- DeleteDC(dc);
-
- if (errorStatus == XpmSuccess)
- return TRUE; /* no error */
- else
- return FALSE;
+ {
+ /* for following SetPixel */
+ /* fill the XImage struct 'by hand' */
+ ximage.width = M_BITMAPHANDLERDATA->m_width;
+ ximage.height = M_BITMAPHANDLERDATA->m_height;
+ ximage.depth = M_BITMAPHANDLERDATA->m_depth;
+ ximage.bitmap = (HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap;
+ int errorStatus = XpmWriteFileFromImage(&dc, WXSTRINGCAST name,
+ &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 return FALSE;
#else
- return FALSE;
+ return FALSE;
#endif
}