Hello,
there is bug in Blit function, when using BlendMode.Alpha.
instead of code
if (blendMode == BlendMode.Alpha)
{
var isa = 255 - sa;
#if NETFX_CORE
// Special case for WinRT since it does not use pARGB (pre-multiplied alpha)
destPixel = ((da & 0xff) << 24) |
((((sr * sa + isa * dr) >> 8) & 0xff) << 16) |
((((sg * sa + isa * dg) >> 8) & 0xff) << 8) |
(((sb * sa + isa * db) >> 8) & 0xff);
#else
destPixel =
((((sa << 8) + isa * da) >> 8) << 24) |
(((((sr << 8) + isa * dr) >> 8) & 0xff) << 16) |
(((((sg << 8) + isa * dg) >> 8) & 0xff) << 8) |
((((sb << 8) + isa * db) >> 8) & 0xff);
#endif
}
should be
if (BlendMode == BlendMode.Alpha)
{
var isa = 255 - sa;
#if NETFX_CORE
// Special case for WinRT since it does not use pARGB (pre-multiplied alpha)
destPixel = ((da & 0xff) << 24) |
((((sr * sa + isa * dr) >> 8) & 0xff) << 16) |
((((sg * sa + isa * dg) >> 8) & 0xff) << 8) |
(((sb * sa + isa * db) >> 8) & 0xff);
#else
destPixel = ((da & 0xff) << 24) |
(((((sr * sa) + isa * dr) >> 8) & 0xff) << 16) |
(((((sg * sa) + isa * dg) >> 8) & 0xff) << 8) |
((((sb * sa) + isa * db) >> 8) & 0xff);
#endif
}
(instead of (((sr << 8) + isa * dr) >> 8) should be (((sr * sa + isa * dr) >> 8), difference in A component is not subject of this issue
Tested with some icons, fixed version renders nice blended icons
there is bug in Blit function, when using BlendMode.Alpha.
instead of code
if (blendMode == BlendMode.Alpha)
{
var isa = 255 - sa;
#if NETFX_CORE
// Special case for WinRT since it does not use pARGB (pre-multiplied alpha)
destPixel = ((da & 0xff) << 24) |
((((sr * sa + isa * dr) >> 8) & 0xff) << 16) |
((((sg * sa + isa * dg) >> 8) & 0xff) << 8) |
(((sb * sa + isa * db) >> 8) & 0xff);
#else
destPixel =
((((sa << 8) + isa * da) >> 8) << 24) |
(((((sr << 8) + isa * dr) >> 8) & 0xff) << 16) |
(((((sg << 8) + isa * dg) >> 8) & 0xff) << 8) |
((((sb << 8) + isa * db) >> 8) & 0xff);
#endif
}
should be
if (BlendMode == BlendMode.Alpha)
{
var isa = 255 - sa;
#if NETFX_CORE
// Special case for WinRT since it does not use pARGB (pre-multiplied alpha)
destPixel = ((da & 0xff) << 24) |
((((sr * sa + isa * dr) >> 8) & 0xff) << 16) |
((((sg * sa + isa * dg) >> 8) & 0xff) << 8) |
(((sb * sa + isa * db) >> 8) & 0xff);
#else
destPixel = ((da & 0xff) << 24) |
(((((sr * sa) + isa * dr) >> 8) & 0xff) << 16) |
(((((sg * sa) + isa * dg) >> 8) & 0xff) << 8) |
((((sb * sa) + isa * db) >> 8) & 0xff);
#endif
}
(instead of (((sr << 8) + isa * dr) >> 8) should be (((sr * sa + isa * dr) >> 8), difference in A component is not subject of this issue
Tested with some icons, fixed version renders nice blended icons