Artifacts on translucent WritableBitmap
See original GitHub issueI drawed translucent WritableBitmap on Bitmap with alpha channel and catched some interesting artifacts. This problem reproduce on Skia and Win32, on Direct2D1 is OK.
View:
<Grid>
<Image Source="{Binding Bitmap}" />
<Image Source="{Binding Background}" />
</Grid>
ViewModel:
Background = new Bitmap(PATH_TO_BACKGROUND_FILE);
var data = new byte[256 * 256 * 4];
for (int y = 0; y < 256; y++) {
for (int x = 0; x < 256; x++) {
var pos = (y * 256 + x) * 4;
data[pos] = 255;
data[pos + 1] = 255;
data[pos + 2] = 255;
data[pos + 3] = 1;
}
}
var writeableBitmap = new WriteableBitmap(256, 256, PixelFormat.Rgba8888);
using (var l = writeableBitmap.Lock()) {
for (var r = 0; r < 256; r++) {
Marshal.Copy(data, r * l.RowBytes, new IntPtr(l.Address.ToInt64() + r * l.RowBytes), l.RowBytes);
}
}
WritableBitmap = writeableBitmap;
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (17 by maintainers)
Top Results From Across the Web
SaveJpeg causing "shadows" artifacts with transparency
Just wanted to check one thing with you. I'm using WriteableBitmap to create an image that I'm as a live tile. Works fine...
Read more >Artifacts in translucent mode - Rendering
Hi to all. I am having some troubles with a skirt I have in my scene when I am changing its material to...
Read more >WriteableBitmapEx - RSSing.com
I am trying to apply an transparent image (in png format) over background image. The result is not very good as applied image...
Read more >Silverlight and WriteableBitmap
I've just released a library to CodePlex that implements a feature missing from Silverlight: the ability to generate bitmaps from pixels in ...
Read more >Rendering RadRichTextPageView to an Image
Hi Oliver, Rendering the document on an image using WriteableBitmap produces artifacts. We currently don't know of a way to render the document ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this is the same problem as https://github.com/AvaloniaUI/Avalonia/issues/2604 and that the alpha needs pre-multiplying for the WriteableBitmap. This is with pre mmultiplied alpha:-
https://github.com/AvaloniaUI/Avalonia/blob/f0a8e64189c7bf60ce7486a35e4a0a67ca644d18/src/Windows/Avalonia.Direct2D1/PrimitiveExtensions.cs#L99 we are using Format32bppPBGRA and Format32bppPRGBA pixel formats. Direct2D might be doing some preprocessing after image bits are unlocked.