Open Ervin304 opened 1 year ago
Error occurs when running the following code: MemoryStream strm = new MemoryStream(); img.Save(strm, System.Drawing.Imaging.ImageFormat.Png); strm.Position = 0;
PdfSharpCore.Drawing.XImage pdfimage = PdfSharpCore.Drawing.XImage.FromStream(() => strm);
Error details:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'SixLabors.ImageSharp.Image1<!!0> SixLabors.ImageSharp.Image.Load(System.IO.Stream, SixLabors.ImageSharp.Formats.IImageFormat ByRef)'. Source=PdfSharpCore StackTrace: at PdfSharpCore.Utils.ImageSharpImageSource
1.FromStreamImpl(String name, Func1 imageStream, Nullable
1 quality)
at MigraDocCore.DocumentObjectModel.MigraDoc.DocumentObjectModel.Shapes.ImageSource.FromStream(String name, Func1 imageStream, Nullable
1 quality)
at PdfSharpCore.Drawing.XImage..ctor(Func1 stream) at PdfSharpCore.Drawing.XImage.FromStream(Func
1 stream)
at x.
I can't create an xImage object from the MemoryStream of a png image I get from Azure blob storage. I always get IvalidFormatException.
The problem are these lines (PdfSharpCore.Utils.ImageSharpImageSource.cs)
using (var stream = imageStream.Invoke()) { var image = Image.Load(stream, out IImageFormat imgFormat);
return new ImageSharpImageSourceImpl(name, image, (int)quality, imgFormat is PngFormat);
}
You should implement somethink like this:
using (var MemoryStream= imageStream.Invoke()) { var image = Image.Load(stream.ToArray(), out IImageFormat imgFormat);
return new ImageSharpImageSourceImpl(name, image, (int)quality, imgFormat is PngFormat);
}