You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "John Hewson (JIRA)" <ji...@apache.org> on 2014/09/01 00:20:21 UTC

[jira] [Comment Edited] (PDFBOX-1094) Pattern colorspace support

    [ https://issues.apache.org/jira/browse/PDFBOX-1094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14116905#comment-14116905 ] 

John Hewson edited comment on PDFBOX-1094 at 8/31/14 10:19 PM:
---------------------------------------------------------------

I figured it out (the scaling that is, not the new issue with the Braun file), as you say getAnchorRect() is the 2nd parameter in the constructor, so we're already passing a Rectangle2D.Float as the anchor rectangle which AWT uses to do the tiling. So we're not limited to integer tilings, which means that the issue is that we're creating the raster too small, we just need to use Math.ceil when sizing the raster:

Replace:

{code}
Rectangle2D rect = getTransformedRect(pattern, matrix);
int width = (int)Math.ceil((float) rect.getWidth());
int height = (int)Math.ceil((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;
}
{code}

With:

{code}
Rectangle2D rect = getTransformedRect(pattern, matrix);
float width = (float)rect.getWidth();
float height = (float)rect.getHeight();

int rasterWidth = Math.max(1, (int)Math.ceil(width * Math.abs(xform.getScaleX())));
int rasterHeight = Math.max(1, (int)Math.ceil(height * Math.abs(xform.getScaleY())));
{code}

You can see the difference in the blue circles in the top-right of tiling_pattern.pdf, previously they were slightly clipped.


was (Author: jahewson):
I figured it out, as you say getAnchorRect() is the 2nd parameter in the constructor, so we're already passing a Rectangle2D.Float as the anchor rectangle which AWT uses to do the tiling. So we're not limited to integer tilings, which means that the issue is that we're creating the raster too small, we just need to use Math.ceil when sizing the raster:

Replace:

{code}
Rectangle2D rect = getTransformedRect(pattern, matrix);
int width = (int)Math.ceil((float) rect.getWidth());
int height = (int)Math.ceil((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;
}
{code}

With:

{code}
Rectangle2D rect = getTransformedRect(pattern, matrix);
float width = (float)rect.getWidth();
float height = (float)rect.getHeight();

int rasterWidth = Math.max(1, (int)Math.ceil(width * Math.abs(xform.getScaleX())));
int rasterHeight = Math.max(1, (int)Math.ceil(height * Math.abs(xform.getScaleY())));
{code}

You can see the difference in the blue circles in the top-right of tiling_pattern.pdf, previously they were slightly clipped.

> 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
>            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, gs-bugzilla693653.pdf, 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.3.4#6332)