Browse Source

Use SKBitmap.Decode method

pull/717/head
Wiesław Šoltés 10 years ago
parent
commit
c91ee0fb61
  1. 21
      src/Skia/Avalonia.Skia/PlatformRenderInterface.cs

21
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");
}
}
}

Loading…
Cancel
Save