Skip to content

Bitmap.DecodeToWidth() fails in 0.10.11, 0.10.12 and 0.10.13 #7773

@stakira

Description

@stakira

Describe the bug
Fails to load bitmap in 0.10.11, 0.10.12 and 0.10.13. Succeeds in 0.10.10 and earlier.

System.ArgumentNullException: Value cannot be null. (Parameter 'buffer')
   at SkiaSharp.SKManagedStream.OnReadManagedStream(IntPtr buffer, IntPtr size)
   at SkiaSharp.SKManagedStream.OnRead(IntPtr buffer, IntPtr size)
   at SkiaSharp.SKAbstractManagedStream.ReadInternal(IntPtr s, Void* context, Void* buffer, IntPtr size)
   at SkiaSharp.SkiaApi.sk_codec_get_pixels(IntPtr codec, SKImageInfoNative* info, Void* pixels, IntPtr rowBytes, SKCodecOptionsInternal* options)
   at SkiaSharp.SKCodec.GetPixels(SKImageInfo info, IntPtr pixels, Int32 rowBytes, SKCodecOptions options)
   at SkiaSharp.SKCodec.GetPixels(SKImageInfo info, IntPtr pixels)
   at SkiaSharp.SKBitmap.Decode(SKCodec codec, SKImageInfo bitmapInfo)
   at Avalonia.Skia.ImmutableBitmap..ctor(Stream stream, Int32 decodeSize, Boolean horizontal, BitmapInterpolationMode interpolationMode) in /_/src/Skia/Avalonia.Skia/ImmutableBitmap.cs:line 69
   at Avalonia.Skia.PlatformRenderInterface.LoadBitmapToWidth(Stream stream, Int32 width, BitmapInterpolationMode interpolationMode) in /_/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs:line 124
   at Avalonia.Media.Imaging.Bitmap.DecodeToWidth(Stream stream, Int32 width, BitmapInterpolationMode interpolationMode) in /_/src/Avalonia.Visuals/Media/Imaging/Bitmap.cs:line 24

I believe it is due to using SkiaSharp 2.88.0-preview.178 since 0.10.11: mono/SkiaSharp#1752 mono/SkiaSharp#1551

To Reproduce

using (var memoryStream = new MemoryStream(path)) {
    var bitmap = Bitmap.DecodeToWidth(memoryStream, 80); 
}

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 0.10.13

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions