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:
@@ -98,6 +98,7 @@ wxMSW:
|
|||||||
|
|
||||||
- Fixed version script problems when using configure with cygwin/mingw32.
|
- Fixed version script problems when using configure with cygwin/mingw32.
|
||||||
- Use system default paper size for printing instead of A4
|
- Use system default paper size for printing instead of A4
|
||||||
|
- Fix colours when converting wxBitmap with alpha to wxImage (nusi)
|
||||||
|
|
||||||
2.7.2
|
2.7.2
|
||||||
-----
|
-----
|
||||||
|
@@ -775,14 +775,26 @@ wxImage wxDIB::ConvertToImage() const
|
|||||||
dst[1] = *src++;
|
dst[1] = *src++;
|
||||||
dst[0] = *src++;
|
dst[0] = *src++;
|
||||||
|
|
||||||
dst += 3;
|
|
||||||
|
|
||||||
if ( is32bit )
|
if ( is32bit )
|
||||||
{
|
{
|
||||||
if ( alpha )
|
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++;
|
src++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dst += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// pass to the previous line in the image
|
// pass to the previous line in the image
|
||||||
|
Reference in New Issue
Block a user