From c91ee0fb617e8228d654acca2da0349108fe954a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Mon, 5 Sep 2016 22:33:46 +0200 Subject: [PATCH] Use SKBitmap.Decode method --- .../Avalonia.Skia/PlatformRenderInterface.cs | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs index cb6d0547e9..8f41265454 100644 --- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs +++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs @@ -32,21 +32,14 @@ namespace Avalonia.Skia { using (var s = new SKManagedStream(stream)) { - using (var codec = SKCodec.Create(s)) + var bitmap = SKBitmap.Decode(s); + if (bitmap != null) { - var info = codec.Info; - var bitmap = new SKBitmap(info.Width, info.Height, SKImageInfo.PlatformColorType, info.IsOpaque ? SKAlphaType.Opaque : SKAlphaType.Premul); - - IntPtr length; - var result = codec.GetPixels(bitmap.Info, bitmap.GetPixels(out length)); - if (result == SKCodecResult.Success || result == SKCodecResult.IncompleteInput) - { - return new BitmapImpl(bitmap); - } - else - { - throw new ArgumentException("Unable to load bitmap from provided data"); - } + return new BitmapImpl(bitmap); + } + else + { + throw new ArgumentException("Unable to load bitmap from provided data"); } } }