I get an "
Unsupported image format" when trying to load and image from a file using PdfSharp.Drawing.XImage in a .NET 7.0 project using PDFSharp 6.0.0-preview-2 and trying to read a .png --
works for .jpg.Code:
using (XImage image = XImage.FromFile(imageFilepath))
I am able to XFont, XBrushes and XGraphics to add text.This is supposed to work, right? I read in the docs that .png is already supported.Are there any tricks?
PS I do have
Code:
GlobalFontSettings.FontResolver = new FailsafeFontResolver();
in my Program.cs
PSS I also tried to load the same image from a stream with the same results.
Code:
MemoryStream ms = new MemoryStream();
using (FileStream fs = new FileStream(imageFilepath, FileMode.Open))
{
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, bytesRead);
}
}
XImage image = XImage.FromStream(ms);