diff --git a/pdfbox/pom.xml b/pdfbox/pom.xml index 340dd3328c1..7f6d15d7233 100644 --- a/pdfbox/pom.xml +++ b/pdfbox/pom.xml @@ -1033,6 +1033,19 @@ 0d7160a4af04bf2f785bf4155f69876da4b7ff7a196e7eda1eb904c02c35aa03c31041d9339fda90322cb58bde16b87bae8460c617bfe5b8dc0670ddab102f62 + + PDFBOX-6232 + generate-test-resources + + wget + + + https://issues.apache.org/jira/secure/attachment/13083774/pdfbox_softmask_regression_ipfree.pdf + ${project.build.directory}/pdfs + PDFBOX-6232-softmask-in-tiling-pattern-in-isolated-group.pdf + 83921c4d53e482afb31bff310850a2d05b689e7d9b6ef03891b700b14d1c6015e728763731f633f79356c4358b9d3717ef4a7428cce6530f5df3bd8e0cb9978c + + diff --git a/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java b/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java index af18a07ebbc..f24b5a1720f 100644 --- a/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java +++ b/pdfbox/src/test/java/org/apache/pdfbox/rendering/TestQuality.java @@ -126,4 +126,33 @@ void testPDFBox5403() throws IOException "expected a dark text pixel but was too light: " + Integer.toHexString(rgb)); } } + + /** + * PDFBOX-6232: a luminosity soft mask (driven by a shading-pattern gradient) applied inside a + * tiling pattern that is itself used within an isolated transparency group must be positioned + * using the enclosing group's coordinate system, not the tiling pattern's own tile raster. + * Before the fix, the mask was sampled at the wrong offset, so the pattern's gradient collapsed + * towards the backdrop color instead of showing its full-strength color partway down the + * gradient. + * + * @throws IOException + */ + @Test + void testPDFBox6232() throws IOException + { + File file = new File(TARGET_PDF_DIR, "PDFBOX-6232-softmask-in-tiling-pattern-in-isolated-group.pdf"); + try (PDDocument doc = Loader.loadPDF(file)) + { + PDFRenderer renderer = new PDFRenderer(doc); + BufferedImage renderedImage = renderer.renderImageWithDPI(0, 100); + // a pixel partway down the gradient, which must be a saturated blue; before the fix, + // the broken mask offset made it collapse towards the dark backdrop colour instead + // (blue channel ~80 instead of ~220, as reported in the JIRA issue) + int rgb = renderedImage.getRGB(413, 294); + int blue = rgb & 0xFF; + Assertions.assertTrue(blue > 150, + "expected a saturated blue gradient pixel but was too dark: " + + Integer.toHexString(rgb)); + } + } }