Skip to content

Commit

Permalink
Merge pull request #8601 from AvaloniaUI/fixes/7773-skia-stream-worka…
Browse files Browse the repository at this point in the history
…round

Workaround for SkiaSharp broken image decoding.
  • Loading branch information
kekekeks authored Jul 26, 2022
2 parents 0614b86 + fd28b7b commit 4be332a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Skia/Avalonia.Skia/ImmutableBitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public ImmutableBitmap(ImmutableBitmap src, PixelSize destinationSize, BitmapInt
public ImmutableBitmap(Stream stream, int decodeSize, bool horizontal, BitmapInterpolationMode interpolationMode)
{
using (var skStream = new SKManagedStream(stream))
using (var codec = SKCodec.Create(skStream))
using (var skData = SKData.Create(skStream))
using (var codec = SKCodec.Create(skData))
{
var info = codec.Info;

Expand Down
7 changes: 4 additions & 3 deletions src/Skia/Avalonia.Skia/WriteableBitmapImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using Avalonia.Skia.Helpers;
using Avalonia.Media.Imaging;
using SkiaSharp;

namespace Avalonia.Skia
Expand All @@ -25,8 +24,9 @@ internal class WriteableBitmapImpl : IWriteableBitmapImpl, IDrawableBitmapImpl
public WriteableBitmapImpl(Stream stream)
{
using (var skiaStream = new SKManagedStream(stream))
using (var skData = SKData.Create(skiaStream))
{
_bitmap = SKBitmap.Decode(skiaStream);
_bitmap = SKBitmap.Decode(skData);

if (_bitmap == null)
{
Expand All @@ -41,7 +41,8 @@ public WriteableBitmapImpl(Stream stream)
public WriteableBitmapImpl(Stream stream, int decodeSize, bool horizontal, BitmapInterpolationMode interpolationMode)
{
using (var skStream = new SKManagedStream(stream))
using (var codec = SKCodec.Create(skStream))
using (var skData = SKData.Create(skStream))
using (var codec = SKCodec.Create(skData))
{
var info = codec.Info;

Expand Down

0 comments on commit 4be332a

Please sign in to comment.