private static Rectangle clipRegion(PDImage pdImage, Rectangle region) { if (region == null) { return new Rectangle(0, 0, pdImage.getWidth(), pdImage.getHeight()); } else { int x = Math.max(0, region.x); int y = Math.max(0, region.y); int width = Math.min(region.width, pdImage.getWidth() - x); int height = Math.min(region.height, pdImage.getHeight() - y); return new Rectangle(x, y, width, height); } }
/** * Calculated the subsampling frequency for a given PDImage based on the current transformation * and its calculated transform * * @param pdImage PDImage to be drawn * @param at Transform that will be applied to the image when drawing * @return The rounded-down ratio of image pixels to drawn pixels. Returned value will always be * >=1. */ private int getSubsampling(PDImage pdImage, AffineTransform at) { // calculate subsampling according to the resulting image size double scale = Math.abs(at.getDeterminant() * xform.getDeterminant()); int subsampling = (int) Math.floor(Math.sqrt(pdImage.getWidth() * pdImage.getHeight() / scale)); if (subsampling > 8) { subsampling = 8; } if (subsampling < 1) { subsampling = 1; } if (subsampling > pdImage.getWidth() || subsampling > pdImage.getHeight()) { // For very small images it is possible that the subsampling would imply 0 size. // To avoid problems, the subsampling is set to no less than the smallest dimension. subsampling = Math.min(pdImage.getWidth(), pdImage.getHeight()); } return subsampling; }
int height = pdImage.getHeight();
pdImage.getHeight() < Math.round(at.getScaleY());
final float[] decode = getDecodeArray(pdImage); if (width <= 0 || height <= 0 || pdImage.getWidth() <= 0 || pdImage.getHeight() <= 0)
private static Rectangle clipRegion(PDImage pdImage, Rectangle region) { if (region == null) { return new Rectangle(0, 0, pdImage.getWidth(), pdImage.getHeight()); } else { int x = Math.max(0, region.x); int y = Math.max(0, region.y); int width = Math.min(region.width, pdImage.getWidth() - x); int height = Math.min(region.height, pdImage.getHeight() - y); return new Rectangle(x, y, width, height); } }
/** * Calculated the subsampling frequency for a given PDImage based on the current transformation * and its calculated transform * * @param pdImage PDImage to be drawn * @param at Transform that will be applied to the image when drawing * @return The rounded-down ratio of image pixels to drawn pixels. Returned value will always be * >=1. */ private int getSubsampling(PDImage pdImage, AffineTransform at) { // calculate subsampling according to the resulting image size double scale = Math.abs(at.getDeterminant() * xform.getDeterminant()); int subsampling = (int) Math.floor(Math.sqrt(pdImage.getWidth() * pdImage.getHeight() / scale)); if (subsampling > 8) { subsampling = 8; } if (subsampling < 1) { subsampling = 1; } if (subsampling > pdImage.getWidth() || subsampling > pdImage.getHeight()) { // For very small images it is possible that the subsampling would imply 0 size. // To avoid problems, the subsampling is set to no less than the smallest dimension. subsampling = Math.min(pdImage.getWidth(), pdImage.getHeight()); } return subsampling; }
int height = pdImage.getHeight();
final int height = pdImage.getHeight(); final float[] decode = getDecodeArray(pdImage); BufferedImage bim = null;
pdImage.getHeight() < Math.round(at.getScaleY());
int height = pdImage.getHeight();
pdImage.getHeight() < Math.round(at.getScaleY());
final int height = pdImage.getHeight(); final int numComponents = pdImage.getColorSpace().getNumberOfComponents(); byte[] tempBytes = new byte[numComponents * width];
final float[] decode = getDecodeArray(pdImage); if (width <= 0 || height <= 0 || pdImage.getWidth() <= 0 || pdImage.getHeight() <= 0)
final int numComponents = colorSpace.getNumberOfComponents(); final int width = pdImage.getWidth(); final int height = pdImage.getHeight(); final int bitsPerComponent = pdImage.getBitsPerComponent(); final float[] decode = getDecodeArray(pdImage);
final int numComponents = colorSpace.getNumberOfComponents(); final int width = pdImage.getWidth(); final int height = pdImage.getHeight(); final int bitsPerComponent = pdImage.getBitsPerComponent(); final float[] decode = getDecodeArray(pdImage);