Search code examples
xamarinxamarin.formsportable-class-libraryskiasharp

SkiaSharp and Xamarin.Forms - unable to decode png


When using the following code in a PCL, I get an ArgumentNullException for parameter name codec.

using (var stream = new SKFileStream("image.png"))
using (var bitmap = SKBitmap.Decode(stream)) { 
    ...
}

The exception is thrown in SKBitmap.Decode. I can verify that the image is a valid PNG file and that the stream's length is greater than 0.

Do I need to install codecs separately or something? I don't see anything about it in the samples.


Solution

  • By disabling PNG optimization (pngcrush) under iOS Build settings, I was able to resolve the issue.