diff --git a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs index eb011cf2a..7b41615c7 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/GithubIssuesTests.cs @@ -7,6 +7,24 @@ public class GithubIssuesTests { + [Fact] + public void Issue982() + { + var path = IntegrationHelpers.GetSpecificTestDocumentPath("PDFBOX-659-0.pdf"); + + using (var document = PdfDocument.Open(path)) + { + for (int p = 1; p <= document.NumberOfPages; ++p) + { + var page = document.GetPage(p); + foreach (var pdfImage in page.GetImages()) + { + Assert.True(pdfImage.TryGetPng(out _)); + } + } + } + } + [Fact] public void Issue973() { @@ -25,11 +43,11 @@ public void Issue973() using (var document = PdfDocument.Open(path, new ParsingOptions() { UseLenientParsing = false })) { var exception = Assert.Throws(() => document.GetPage(2)); - Assert.Equal("Cannot execute a pop of the graphics state stack, it would leave the stack empty.", exception.Message); + Assert.Equal("Cannot execute a pop of the graphics state stack, it would leave the stack empty.", + exception.Message); } } - [Fact] public void Issue959() { diff --git a/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/PDFBOX-659-0.pdf b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/PDFBOX-659-0.pdf new file mode 100644 index 000000000..db395d766 Binary files /dev/null and b/src/UglyToad.PdfPig.Tests/Integration/SpecificTestDocuments/PDFBOX-659-0.pdf differ diff --git a/src/UglyToad.PdfPig/Filters/CcittFaxDecodeFilter.cs b/src/UglyToad.PdfPig/Filters/CcittFaxDecodeFilter.cs index 21d4d8565..7bce8d665 100644 --- a/src/UglyToad.PdfPig/Filters/CcittFaxDecodeFilter.cs +++ b/src/UglyToad.PdfPig/Filters/CcittFaxDecodeFilter.cs @@ -6,6 +6,8 @@ using CcittFax; using Util; + // Filter updated from original port because of issue #982 + /// /// Decodes image data that has been encoded using either Group 3 or Group 4. /// @@ -62,11 +64,6 @@ private static CcittFaxCompressionType DetermineCompressionType(ReadOnlySpan> 4 != 1 && input[1] != 1)) { // leading EOL (0b000000000001) not found, search further and @@ -114,7 +111,8 @@ private static void InvertBitmap(Span bufferData) { for (int i = 0, c = bufferData.Length; i < c; i++) { - bufferData[i] = (byte)(~bufferData[i] & 0xFF); + ref byte b = ref bufferData[i]; + b = (byte)(~b & 0xFF); } } }