Open ErisLoona opened 1 week ago
I can reproduce. As a workaround, copying to a MemoryStream
beforehand works for me. Probably still a bug though so keep the issue open.
eg.
using var entryStream = entry.Open();
using var memory = new MemoryStream();
entryStream.CopyTo(memory);
memory.Seek(0, SeekOrigin.Begin);
CoverImage.Source = new Bitmap(memory);
For reproducing:
using ZipArchive archive = ZipFile.OpenRead(@"D:\avalonia-logo.zip"); // Fixup path
foreach (ZipArchiveEntry entry in archive.Entries)
{
if (entry.Name == "avalonia-logo.png")
{
using var entryStream = entry.Open();
using var bitmap = new Bitmap(entryStream);
}
}
The culprit could be an unsupported scenario in SkiaSharp:
I don't know the SK* APIs well, but Avalonia could write some specialized code for DeflateStream
. It lacks certain capabilities such as Position
, Length
, and seeking.
Describe the bug
Heyo! When using
Avalonia.Media.Imaging.Bitmap
, usingnew Bitmap()
on a Stream provided by aSystem.IO.Compression.ZipArchiveEntry
throws the error "Unable to load bitmap from provided data". In my testing on the same file,System.Drawing.Bitmap
works with no issues.To Reproduce
I have the following code:
I have also tried
Bitmap b = new Bitmap(entry.Open());
instead with the same result.Expected behavior
No response
Avalonia version
11.1.4
OS
No response
Additional context
No response