SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG] SKBitmap pixels are premultiplied, even if specified un-premultiplied at constructor.

Open MathieuJack opened this issue 5 years ago • 4 comments

SKBitmap pixels are premultiplied, even if specified un-premultiplied at constructor.

        SKBitmap bmp = new SKBitmap(16,16, SKColorType.Rgba8888, SKAlphaType.Unpremul);
        bmp.SetPixel(0, 0, new SKColor(red: 255, green:255,blue:255,alpha:100));
        byte[] bytes = bmp.Bytes;

        Assert.IsTrue(bytes[0] == 255); //Blue. Expected 255, result 100
        Assert.IsTrue(bytes[1] == 255); //Green. Expected 255, result 100
        Assert.IsTrue(bytes[2] == 255); //Red. Expected 255, result 100
        Assert.IsTrue(bytes[3] == 100); //Alpha. Expected 100, result 100

Note : Chaning the SKAlphaType value to Opaque or Premultiplied does not change the result.

  • Version with issue: 1.60.3
  • Last known good version: N/A
  • IDE: Visual Studio
  • Platform Target Frameworks: Full Framework / Windows 10

VS bug #782039

MathieuJack avatar Jan 25 '19 20:01 MathieuJack