SkiaSharp icon indicating copy to clipboard operation
SkiaSharp copied to clipboard

[BUG] SkiaSharp Gray8 decoding returns null

Open CoenraadS opened this issue 7 years ago • 4 comments

Description

In SkiaSharp 1.60.3 loading an 8bit png would result in a bitmap with BytesPerPixel == 1. In 1.68.0, BytesPerPixel == 4

Apparently now we need to pass in the codec when decoding to tell Skia it is an 8 bit image. https://github.com/mono/SkiaSharp/issues/694#issuecomment-441078401

Code

// bytes = File.ReadAllBytes(....)
var stream = new MemoryStream(bytes);
var codec = SKCodec.Create(stream);
var imageInfo = new SKImageInfo(codec.Info.Width, codec.Info.Height, SKColorType.Gray8);
var bitmap = SKBitmap.Decode(codec, imageInfo);

Expected Behavior

BytesPerPixel == 1

Actual Behavior

bitmap == null

Basic Information

  • Version with issue: 1.68.0
  • Last known good version: 1.60.3
  • IDE: Visual Studio Code
  • Platform Target Frameworks: netcoreapp3.0

Screenshots

Reproduction Link

Input image: 201812211019388645_validpos_19 19875_21 285_439_12

VS bug #770226

CoenraadS avatar Jan 12 '19 18:01 CoenraadS

Thanks for reporting this, I will investigate. I also get the null result when I believe it should be working.

mattleibow avatar Jan 16 '19 05:01 mattleibow

Same issue here. I'm using SkiaSharp 1.68.0.

felipesouto avatar Mar 06 '20 16:03 felipesouto

Is this still an issue?

sbartolett3 avatar Mar 30 '23 15:03 sbartolett3

This issue still persists in version 3.119.1. Are there plans to address it in the future?

liu7923032 avatar Jan 29 '26 03:01 liu7923032