// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "bitmap.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// Create from XPM data
bool wxBitmap::CreateFromXpm(const char **data)
{
-#if wxUSE_IMAGE && wxUSE_XPM
+#if wxUSE_IMAGE && wxUSE_XPM && wxUSE_WXDIB
Init();
wxCHECK_MSG( data != NULL, false, wxT("invalid bitmap data") )
wxDIB dib(image);
if ( !dib.IsOk() )
return false;
-
+ if (depth == -1)
+ depth = dib.GetDepth(); // Get depth from image if none specified
// store the bitmap parameters
wxBitmapRefData *refData = new wxBitmapRefData;
hbitmap = dib.Detach();
refData->m_isDIB = true;
- refData->m_depth = dib.GetDepth();
+ refData->m_depth = depth;
}
#ifndef ALWAYS_USE_DIB
else // we need to convert DIB to DDB
{
hbitmap = dib.CreateDDB((HDC)hdc);
- refData->m_depth = depth == -1 ? dib.GetDepth() : depth;
+ refData->m_depth = depth;
}
#endif // !ALWAYS_USE_DIB
return handler->LoadFile(this, filename, type, -1, -1);
}
-#if wxUSE_IMAGE
+#if wxUSE_IMAGE && wxUSE_WXDIB
else // no bitmap handler found
{
wxImage image;
{
return handler->SaveFile(this, filename, type, palette);
}
-#if wxUSE_IMAGE
+#if wxUSE_IMAGE && wxUSE_WXDIB
else // no bitmap handler found
{
// FIXME what about palette? shouldn't we use it?
#ifndef __WXMICROWIN__
// handle alpha channel, if any
if (HasAlpha())
- ret.UseAlpha();
+ ret.UseAlpha();
// copy bitmap data
MemoryHDC dcSrc,
return 0;
}
- wxMask* mask;
- wxBitmap newbmp;
if ( bmp.HasAlpha() )
{
- // Convert alpha to a mask. NOTE: It would be better to actually put
- // the alpha into the icon instead of making a mask, but I don't have
- // time to figure that out today.
- wxImage img = bmp.ConvertToImage();
- img.ConvertAlphaToMask();
- newbmp = wxBitmap(img);
- mask = newbmp.GetMask();
- }
- else
- {
- mask = bmp.GetMask();
+ // Create an empty mask bitmap.
+ // it doesn't seem to work if we mess with the mask at all.
+ HBITMAP hMonoBitmap = CreateBitmap(bmp.GetWidth(),bmp.GetHeight(),1,1,NULL);
+
+ ICONINFO iconInfo;
+ wxZeroMemory(iconInfo);
+ iconInfo.fIcon = iconWanted; // do we want an icon or a cursor?
+ if ( !iconWanted )
+ {
+ iconInfo.xHotspot = hotSpotX;
+ iconInfo.yHotspot = hotSpotY;
+ }
+
+ iconInfo.hbmMask = hMonoBitmap;
+ iconInfo.hbmColor = GetHbitmapOf(bmp);
+
+ HICON hicon = ::CreateIconIndirect(&iconInfo);
+
+ ::DeleteObject(hMonoBitmap);
+
+ return hicon;
}
+ wxMask* mask = bmp.GetMask();
+
if ( !mask )
{
// we must have a mask for an icon, so even if it's probably incorrect,