From 442df1882498263f800b1a1b01573b752147cb4e Mon Sep 17 00:00:00 2001 From: ghosttie Date: Mon, 28 Mar 2022 17:22:56 -0400 Subject: [PATCH] fix negated 1bpp TIFs with Photometric.MINISBLACK --- Pdf/PdfDictionaryExtensions.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Pdf/PdfDictionaryExtensions.cs b/Pdf/PdfDictionaryExtensions.cs index 23b203f..a8a40ec 100644 --- a/Pdf/PdfDictionaryExtensions.cs +++ b/Pdf/PdfDictionaryExtensions.cs @@ -175,6 +175,12 @@ private static Image ImageFromCCITTFaxDecode(PdfDictionary dictionary) for (int i = 0; i < imageData.Height; i++) { tiff.ReadScanline(buffer, i); + if (!ccittFaxDecodeParameters.BlackIs1) { + for (var j = 0; j < buffer.Length; j++) { + buffer[j] = (byte) (255 - buffer[j]); + } + } + Rectangle imgRect = new Rectangle(0, i, imageData.Width, 1); BitmapData imgData = bitmap.LockBits(imgRect, ImageLockMode.WriteOnly, PixelFormat.Format1bppIndexed); Marshal.Copy(buffer, 0, imgData.Scan0, buffer.Length);