empira / PDFsharp

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

ImageSelector hash ignores transparency mask #175

Closed jellemuylle closed 1 month ago

jellemuylle commented 2 months 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 1 month ago

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