Quantcast
Channel: WriteableBitmapEx
Viewing all articles
Browse latest Browse all 360

Commented Issue: Bug in Blit function for WPF [21788]

$
0
0
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
Comments: ** Comment from web user: dbshell **

Hello,
thank you for explanation.
I have used version from official downloads, with some fixes and extension. When upgrading to latest source code version, it works perfectly.
Only when upgrading, FillRectangle function draws rectangles one pixel smaller than previous rectangle... I fixed it in my calling code.
Jan


Viewing all articles
Browse latest Browse all 360

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>