#include "assert.h"
-#if USE_XPM_IN_MSW
+#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;
wxBitmap::wxBitmap(void)
{
- m_refData = NULL; // new wxBitmapRefData;
-
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
wxTheBitmapList->AddBitmap(this);
}
-#if USE_XPM_IN_MSW
+#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() != NULL) );
+/*
+ wxASSERT( 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();
+*/
+ 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 wxBMPFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight)
{
-#if USE_IMAGE_LOADING_IN_MSW
+#if wxUSE_IMAGE_LOADING_IN_MSW
wxPalette *palette = NULL;
bool success = FALSE;
/*
bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *pal)
{
-#if USE_IMAGE_LOADING_IN_MSW
+#if wxUSE_IMAGE_LOADING_IN_MSW
wxPalette *actualPalette = (wxPalette *)pal;
if (!actualPalette && (!M_BITMAPHANDLERDATA->m_bitmapPalette.IsNull()))
actualPalette = & (M_BITMAPHANDLERDATA->m_bitmapPalette);
bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight)
{
-#if USE_XPM_IN_MSW
+#if wxUSE_XPM_IN_MSW
XImage *ximage;
XpmAttributes xpmAttr;
HDC dc;
bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette)
{
-#if USE_XPM_IN_MSW
- HDC dc = NULL;
-
- Visual *visual = NULL;
- XImage ximage;
-
- dc = CreateCompatibleDC(NULL);
- if (dc)
- {
+#if wxUSE_XPM_IN_MSW
+ 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
}
bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth)
{
-#if USE_XPM_IN_MSW
+#if wxUSE_XPM_IN_MSW
XImage *ximage;
int ErrorStatus;
XpmAttributes xpmAttr;