X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5a60b5f0414e4b5663d968344b1aaae861a0797f..0ad966eeac4c245a745c6a2056613f9c7367e4b2:/src/msw/bitmap.cpp diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 015c8309bd..8605d26274 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -17,10 +17,6 @@ // 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" @@ -324,7 +320,7 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon) unsigned char* pixels = dib.GetData(); for (int idx=0; idxm_hasAlpha ) { - // the mask returned by GetIconInfo() is inversed compared to the usual + // the mask returned by GetIconInfo() is inverted compared to the usual // wxWin convention refData->SetMask(wxInvertMask(iconInfo.hbmMask, w, h)); } - + // delete the old one now as we don't need it any more ::DeleteObject(iconInfo.hbmMask); @@ -435,7 +431,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) { // we assume that it is in XBM format which is not quite the same as // the format CreateBitmap() wants because the order of bytes in the - // line is inversed! + // line is reversed! const size_t bytesPerLine = (width + 7) / 8; const size_t padding = bytesPerLine % 2; const size_t len = height * ( padding + bytesPerLine ); @@ -905,7 +901,7 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc) SetMask(new wxMask((WXHBITMAP)hbitmap)); } - delete data; + delete[] data; } return true; @@ -1091,7 +1087,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const #ifndef __WXMICROWIN__ // handle alpha channel, if any if (HasAlpha()) - ret.UseAlpha(); + ret.UseAlpha(); // copy bitmap data MemoryHDC dcSrc, @@ -1250,7 +1246,7 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) HBITMAP hDIB; if ( !GetBitmapData()->m_isDIB ) { - wxCHECK_MSG( !GetBitmapData()->m_dib, FALSE, + wxCHECK_MSG( !GetBitmapData()->m_dib, NULL, _T("GetRawData() may be called only once") ); wxDIB *dib = new wxDIB(*this); @@ -1599,7 +1595,7 @@ bool wxCreateDIB(long xSize, long ySize, long bitsPerPixel, // this value must be 1, 4, 8 or 24 so PixelDepth can only be lpDIBheader->bmiHeader.biBitCount = (WORD)(bitsPerPixel); lpDIBheader->bmiHeader.biCompression = BI_RGB; - lpDIBheader->bmiHeader.biSizeImage = xSize * abs(ySize) * bitsPerPixel >> 3; + lpDIBheader->bmiHeader.biSizeImage = (xSize * abs(ySize) * bitsPerPixel) >> 3; lpDIBheader->bmiHeader.biClrUsed = 256; @@ -1639,7 +1635,23 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, return 0; } - wxMask *mask = bmp.GetMask(); + 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(); + } + if ( !mask ) { // we must have a mask for an icon, so even if it's probably incorrect, @@ -1676,7 +1688,7 @@ HICON wxBitmapToIconOrCursor(const wxBitmap& bmp, HICON hicon = ::CreateIconIndirect(&iconInfo); - if ( !bmp.GetMask() ) + if ( !bmp.GetMask() && !bmp.HasAlpha() ) { // we created the mask, now delete it delete mask;