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 6 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

Thanks for reporting this, I will investigate.

mattleibow avatar Jan 30 '19 22:01 mattleibow

This issue still happens five years later on SkiaSharp 2.88.8

neptuwunium avatar May 31 '24 04:05 neptuwunium

This appears to be fixed in SkiaSharp 3.x releases. let me know if this is not working for you.

mattleibow avatar May 31 '24 16:05 mattleibow

It does appear to be fixed.

neptuwunium avatar Jun 02 '24 07:06 neptuwunium