[ https://issues.apache.org/jira/browse/PDFBOX-1094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14109318#comment-14109318 ]
Tilman Hausherr commented on PDFBOX-1094: ----------------------------------------- I'm passing the xform in every toPaint(). The main change is in TilingPaint.getImage() which looks like this: {code} private static BufferedImage getImage(PDFRenderer renderer, PDTilingPattern pattern, PDColorSpace colorSpace, PDColor color, AffineTransform xform) throws IOException { ColorSpace outputCS = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorModel cm = new ComponentColorModel(outputCS, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE); Rectangle2D rect = getTransformedRect(pattern); int width = Math.round((float) rect.getWidth()); int height = Math.round((float) rect.getHeight()); int rasterWidth = (int) (width * Math.abs(xform.getScaleX())); int rasterHeight = (int) (height * Math.abs(xform.getScaleY())); if (rasterWidth < 1) rasterWidth = 1; if (rasterHeight < 1) rasterHeight = 1; // create raster WritableRaster raster = cm.createCompatibleWritableRaster(rasterWidth, rasterHeight); BufferedImage image = new BufferedImage(cm, raster, false, null); // TODO the pattern matrix needs to map onto the parent stream's initial space, not the CTM // so the transformation below is not correct, because TilingPaint needs more // information to perform the transformation correctly, see PDF 32000, p174. // matrix Matrix matrix; if (pattern.getMatrix() == null) { // identity matrix = new Matrix(); } else { // undo translation matrix = pattern.getMatrix().clone(); matrix.setValue(2, 0, matrix.getValue(2, 0) - (float)rect.getX()); // tx matrix.setValue(2, 1, matrix.getValue(2, 1) - (float)rect.getY()); // ty } // TODO: need to make it easy to use a custom TilingPatternDrawer PageDrawer drawer = new TilingPatternDrawer(renderer); PDRectangle pdRect = new PDRectangle(0, 0, width, height); Graphics2D graphics = image.createGraphics(); graphics.scale(xform.getScaleX(), -xform.getScaleY()); drawer.drawTilingPattern(graphics, pattern, pdRect, matrix, colorSpace, color); graphics.dispose(); return image; } {code} > Pattern colorspace support > -------------------------- > > Key: PDFBOX-1094 > URL: https://issues.apache.org/jira/browse/PDFBOX-1094 > Project: PDFBox > Issue Type: Improvement > Components: Rendering > Affects Versions: 1.6.0 > Reporter: Andreas Lehmkühler > Assignee: Andreas Lehmkühler > Priority: Minor > Attachments: ColoredTilingPaint.patch, PATTYP1.pdf, PATTYP2.pdf, > PDF32000_2008_pg737.pdf, PDFBOX-1094-065514-XStep32767.pdf, > PDFBOX-1094-094730.pdf, PDFBOX-1094-096213-p18.pdf, > PDFBOX-1861-tracemonkey13.png, PDFStreamEngine.patch, PageDrawer.patch, > _pdfbox-1094-tiling_pattern.pdf-1-blurry.png, jagpdf_doc_patterns.pdf, > jagpdf_doc_patterns.pdf-1.png, pdfbox-1094-pdf32000_2008_pg737.pdf-1.png, > pdfbox-1094-pdf32000_2008_pg737.pdf-1.png, > pdfbox-1094-tiling_pattern.pdf-1.png, pdfbox-1094-tiling_pattern.pdf-1.png, > pdfbox-1094-tiling_pattern.pdf-1.png, pdfbox-1861-tracemonkey.pdf-13.png, > pdfbox-1861-tracemonkey.pdf-13.png, tiling_pattern.pdf > > > PDFBox doesn't support PDPattern colorspaces -- This message was sent by Atlassian JIRA (v6.2#6252)