Hi,
decoding from a memory stream fails if the stream position is already at EOF.
In example:
Stream zipStream = ... // get a zipped jpeg
MemoryStream unzippedStream = new MemoryStream();
await zipStream.CopyToAsync(unzippedStream);
Image image = new Image(unzippedStream);
Code above fails with a NotSupportedException "Image cannot be loaded. Available formats: ..." because Image.Decode() find an empty header (Image{TColor].cs line 447) calling stream.Read() at EOF.
The following works:
Stream zipStream = ... // get a zipped jpeg
MemoryStream unzippedStream = new MemoryStream();
await zipStream.CopyToAsync(unzippedStream);
unzippedStream.Position = 0; // add this to reset stream position
Image image = new Image(unzippedStream);
I think Image constructor should set Stream.Position = 0 when decoding images from streams.
Hi,
decoding from a memory stream fails if the stream position is already at EOF.
In example:
Code above fails with a NotSupportedException "Image cannot be loaded. Available formats: ..." because Image.Decode() find an empty header (Image{TColor].cs line 447) calling stream.Read() at EOF.
The following works:
I think Image constructor should set Stream.Position = 0 when decoding images from streams.