empira / PDFsharp

PDFsharp and MigraDoc Foundation for .NET 6 and .NET Framework
https://docs.pdfsharp.net/
Other
492 stars 114 forks source link

ImageSelector hash ignores transparency mask #175

Closed jellemuylle closed 3 days ago

jellemuylle commented 1 week ago

example attached. bug only shows in plain PDFsharp (not in gdi or wpf versions)

if you include 2 transparent PNG images that have identical bitmap data but differ only in the transparency mask data then DrawImage thinks they are the same. only the first image is included in the image table and the second is a repeat.

the root cause is that the ImageSelector that powers the image table uses MD5 hashes that are based on the bitmap data only and not on the transparency mask data. (https://github.com/empira/PDFsharp/blob/master/src/foundation/src/PDFsharp/src/PdfSharp/Pdf.Advanced/PdfImageTable.cs line 80)

Issue.zip

ThomasHoevel commented 3 days ago

Known issue, see #127 Fixed with current internal builds, should be fixed with a forthcoming preview build.