X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47d67540a017101b3e46abe9ef0f55914d8de37e..f8a3e080aaf03010044191b373d27c2e17cbd7d9:/src/msw/bitmap.cpp?ds=inline diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 44099f7598..e935db2c76 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -27,6 +27,7 @@ #include "wx/utils.h" #include "wx/app.h" #include "wx/palette.h" +#include "wx/dcmemory.h" #include "wx/bitmap.h" #include "wx/icon.h" #endif @@ -38,7 +39,7 @@ #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" @@ -78,6 +79,7 @@ wxBitmapRefData::~wxBitmapRefData(void) if (m_bitmapMask) delete m_bitmapMask; m_bitmapMask = NULL; + } wxList wxBitmap::sm_handlers; @@ -170,7 +172,7 @@ wxBitmap::wxBitmap(const wxString& filename, long type) #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); } @@ -394,6 +396,7 @@ wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const LPBITMAPINFO lpDib; void *lpBits = NULL; +/* wxASSERT( this->GetPalette() && this->GetPalette()->Ok() && (this->GetPalette()->GetHPALETTE() != 0) ); tmpBitmap.SetPalette(this->GetPalette()); @@ -401,6 +404,23 @@ wxBitmap wxBitmap::GetBitmapForDC(wxDC& dc) const 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); @@ -739,35 +759,35 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla 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 }