TilingPaint.java (pdfbox-2.0.23-src) | : | TilingPaint.java (pdfbox-2.0.24-src) | ||
---|---|---|---|---|
skipping to change at line 172 | skipping to change at line 172 | |||
graphics.scale(xScale, yScale); | graphics.scale(xScale, yScale); | |||
// apply only the scaling from the pattern transform, doing scaling here improves the | // apply only the scaling from the pattern transform, doing scaling here improves the | |||
// image quality and prevents large scale-down factors from creating hug e tiling cells. | // image quality and prevents large scale-down factors from creating hug e tiling cells. | |||
Matrix newPatternMatrix; | Matrix newPatternMatrix; | |||
newPatternMatrix = Matrix.getScaleInstance( | newPatternMatrix = Matrix.getScaleInstance( | |||
Math.abs(patternMatrix.getScalingFactorX()), | Math.abs(patternMatrix.getScalingFactorX()), | |||
Math.abs(patternMatrix.getScalingFactorY())); | Math.abs(patternMatrix.getScalingFactorY())); | |||
// move origin to (0,0) | // move origin to (0,0) | |||
PDRectangle bbox = pattern.getBBox(); | ||||
newPatternMatrix.concatenate( | newPatternMatrix.concatenate( | |||
Matrix.getTranslateInstance(-pattern.getBBox().getLowerLeftX(), | Matrix.getTranslateInstance(-bbox.getLowerLeftX(), -bbox.getLowe | |||
-pattern.getBBox().getLowerLeftY())); | rLeftY())); | |||
// render using PageDrawer | // render using PageDrawer | |||
drawer.drawTilingPattern(graphics, pattern, colorSpace, color, newPatter nMatrix); | drawer.drawTilingPattern(graphics, pattern, colorSpace, color, newPatter nMatrix); | |||
graphics.dispose(); | graphics.dispose(); | |||
return image; | return image; | |||
} | } | |||
/** | /** | |||
* Returns the closest integer which is larger than the given number. | * Returns the closest integer which is larger than the given number. | |||
skipping to change at line 203 | skipping to change at line 203 | |||
@Override | @Override | |||
public int getTransparency() | public int getTransparency() | |||
{ | { | |||
return Transparency.TRANSLUCENT; | return Transparency.TRANSLUCENT; | |||
} | } | |||
/** | /** | |||
* Returns the anchor rectangle, which includes the XStep/YStep and scaling. | * Returns the anchor rectangle, which includes the XStep/YStep and scaling. | |||
*/ | */ | |||
private Rectangle2D getAnchorRect(PDTilingPattern pattern) | private Rectangle2D getAnchorRect(PDTilingPattern pattern) throws IOExceptio n | |||
{ | { | |||
PDRectangle bbox = pattern.getBBox(); | ||||
if (bbox == null) | ||||
{ | ||||
throw new IOException("Pattern /BBox is missing"); | ||||
} | ||||
float xStep = pattern.getXStep(); | float xStep = pattern.getXStep(); | |||
if (xStep == 0) | if (xStep == 0) | |||
{ | { | |||
xStep = pattern.getBBox().getWidth(); | LOG.warn("/XStep is 0, using pattern /BBox width"); | |||
xStep = bbox.getWidth(); | ||||
} | } | |||
float yStep = pattern.getYStep(); | float yStep = pattern.getYStep(); | |||
if (yStep == 0) | if (yStep == 0) | |||
{ | { | |||
yStep = pattern.getBBox().getHeight(); | LOG.warn("/YStep is 0, using pattern /BBox height"); | |||
yStep = bbox.getHeight(); | ||||
} | } | |||
float xScale = patternMatrix.getScalingFactorX(); | float xScale = patternMatrix.getScalingFactorX(); | |||
float yScale = patternMatrix.getScalingFactorY(); | float yScale = patternMatrix.getScalingFactorY(); | |||
float width = xStep * xScale; | float width = xStep * xScale; | |||
float height = yStep * yScale; | float height = yStep * yScale; | |||
if (Math.abs(width * height) > MAXEDGE * MAXEDGE) | if (Math.abs(width * height) > MAXEDGE * MAXEDGE) | |||
{ | { | |||
// PDFBOX-3653: prevent huge sizes | // PDFBOX-3653: prevent huge sizes | |||
LOG.info("Pattern surface is too large, will be clipped"); | LOG.info("Pattern surface is too large, will be clipped"); | |||
LOG.info("width: " + width + ", height: " + height); | LOG.info("width: " + width + ", height: " + height); | |||
LOG.info("XStep: " + xStep + ", YStep: " + yStep); | LOG.info("XStep: " + xStep + ", YStep: " + yStep); | |||
LOG.info("bbox: " + pattern.getBBox()); | LOG.info("bbox: " + bbox); | |||
LOG.info("pattern matrix: " + pattern.getMatrix()); | LOG.info("pattern matrix: " + pattern.getMatrix()); | |||
LOG.info("concatenated matrix: " + patternMatrix); | LOG.info("concatenated matrix: " + patternMatrix); | |||
width = Math.min(MAXEDGE, Math.abs(width)) * Math.signum(width); | width = Math.min(MAXEDGE, Math.abs(width)) * Math.signum(width); | |||
height = Math.min(MAXEDGE, Math.abs(height)) * Math.signum(height); | height = Math.min(MAXEDGE, Math.abs(height)) * Math.signum(height); | |||
//TODO better solution needed | //TODO better solution needed | |||
} | } | |||
// returns the anchor rect with scaling applied | // returns the anchor rect with scaling applied | |||
PDRectangle anchor = pattern.getBBox(); | return new Rectangle2D.Float(bbox.getLowerLeftX() * xScale, | |||
return new Rectangle2D.Float(anchor.getLowerLeftX() * xScale, | bbox.getLowerLeftY() * yScale, | |||
anchor.getLowerLeftY() * yScale, | ||||
width, height); | width, height); | |||
} | } | |||
} | } | |||
End of changes. 8 change blocks. | ||||
9 lines changed or deleted | 16 lines changed or added |