unmultiply by alpha when converting from wxDIB to wxImage as the former uses premultiplied alpha but the latter does not (patch 1597063)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-11-19 12:35:16 +00:00
parent f52eff546a
commit 0deb5fab34
2 changed files with 16 additions and 3 deletions

View File

@@ -98,6 +98,7 @@ wxMSW:
- Fixed version script problems when using configure with cygwin/mingw32.
- Use system default paper size for printing instead of A4
- Fix colours when converting wxBitmap with alpha to wxImage (nusi)
2.7.2
-----

View File

@@ -775,14 +775,26 @@ wxImage wxDIB::ConvertToImage() const
dst[1] = *src++;
dst[0] = *src++;
dst += 3;
if ( is32bit )
{
if ( alpha )
*alpha++ = *src;
{
// wxImage uses non premultiplied alpha so undo
// premultiplication done in Create() above
const unsigned char a = *src;
*alpha++ = a;
if ( a > 0 )
{
dst[0] = (dst[0] * 255 - 127) / a;
dst[1] = (dst[1] * 255 - 127) / a;
dst[2] = (dst[2] * 255 - 127) / a;
}
}
src++;
}
dst += 3;
}
// pass to the previous line in the image