Open julienrffr opened 10 months ago
I tried your code snippet with the PNG file downloaded from this thread - and everything worked as expected.
I tried your code snippet with the PNG file downloaded from this thread - and everything worked as expected.
@ThomasHoevel With Core build?
I hope also that github image storage does not alter the image by optimizing it. Or your browser.
Your reproduction scenario is visibly different from mine somewhere.
I can reproduce it now. I thought I was using Core build, but VS used a different build. So far I don't see an easy fix.
Take the HelloWorld program of Core build, Add:
var imageStream = File.Open(@"C:\Users\xxx\Downloads\MI6LOGO.png", FileMode.Open, FileAccess.Read); XImage xImage = XImage.FromStream(imageStream); gfx.DrawImage(xImage, 0, 0, 100, 100);
Where MI6LOGO.png is this attached file: It will throw an IndexOutOfRangeException at line https://github.com/empira/PDFsharp/blob/b28bc3265e0a15302c04b7b91da0d915a591e167/src/foundation/src/PDFsharp/src/PdfSharp/PngLib/RawPngData.cs#L54 because paletteIndex = 1 and data has 0 elements.Stack trace:
at PdfSharp.BigGustave.RawPngData.GetPixelIndex(Int32 x, Int32 y) in D:\gitroot\PDFsharp.net6\src\foundation\src\PDFsharp\src\PdfSharp\PngLib\RawPngData.cs:line 54 at PdfSharp.BigGustave.Png.GetPixelIndex(Int32 x, Int32 y) in D:\gitroot\PDFsharp.net6\src\foundation\src\PDFsharp\src\PdfSharp\PngLib\Png.cs:line 52 at PdfSharp.Drawing.Internal.ImageImporterPng.TestPngInfoHeader(StreamReaderHelper stream, ImportedImage ii) in D:\gitroot\PDFsharp.net6\src\foundation\src\PDFsharp\src\PdfSharp\Drawing.Internal\ImageImporterPng.cs:line 307 at PdfSharp.Drawing.Internal.ImageImporterPng.ImportImage(StreamReaderHelper stream) in D:\gitroot\PDFsharp.net6\src\foundation\src\PDFsharp\src\PdfSharp\Drawing.Internal\ImageImporterPng.cs:line 29