public static void displayImageInfo(ImageInfo info) { ImageSize size = info.getSize(); Dimension2D dPt = size.getDimensionPt(); Dimension dPx = size.getDimensionPx(); log.debug(info.getOriginalURI() + " " + info.getMimeType() + " " + Math.round(dPx.getWidth()) + "x" + Math.round(dPx.getHeight())); log.debug("Resolution:" + Math.round(size.getDpiHorizontal()) + "x" + Math.round(size.getDpiVertical())); log.debug("Print size: " + Math.round(dPt.getWidth() / 72) + "\" x" + Math.round(dPt.getHeight() / 72) + "\""); }
public static CxCy scale(ImageInfo imageInfo, double xEmu, double yEmu) { ImageSize size = imageInfo.getSize(); double iwEmu = toEmu(size.getWidthPx(), size.getDpiHorizontal()); double ihEmu = toEmu(size.getHeightPx(), size.getDpiVertical()); return scaleToFit(iwEmu, ihEmu, xEmu, yEmu); }
/** {@inheritDoc} */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("Size: "); sb.append(getWidthMpt()).append('x').append(getHeightMpt()).append(" mpt"); sb.append(" ("); sb.append(getWidthPx()).append('x').append(getHeightPx()).append(" px"); sb.append(" at ").append(getDpiHorizontal()).append('x').append(getDpiVertical()); sb.append(" dpi"); sb.append(")"); return sb.toString(); }
public static void displayImageInfo(ImageInfo info) { ImageSize size = info.getSize(); Dimension2D dPt = size.getDimensionPt(); Dimension dPx = size.getDimensionPx(); log.debug(info.getOriginalURI() + " " + info.getMimeType() + " " + Math.round(dPx.getWidth()) + "x" + Math.round(dPx.getHeight())); log.debug("Resolution:" + Math.round(size.getDpiHorizontal()) + "x" + Math.round(size.getDpiVertical())); log.debug("Print size: " + Math.round(dPt.getWidth() / 72) + "\" x" + Math.round(dPt.getHeight() / 72) + "\""); }
if (dim != null) { Element child; double dpiHorz = size.getDpiHorizontal(); double dpiVert = size.getDpiVertical(); child = getChild(dim, "HorizontalPixelSize");
/** {@inheritDoc} */ public Image convert(Image src, Map hints) throws ImageException, IOException { checkSourceFlavor(src); assert src instanceof ImageRendered; ImageRendered rendered = (ImageRendered)src; ImageWriter writer = ImageWriterRegistry.getInstance().getWriterFor(MimeConstants.MIME_PNG); if (writer == null) { throw new ImageException("Cannot convert image to PNG. No suitable ImageWriter found."); } ByteArrayOutputStream baout = new ByteArrayOutputStream(); ImageWriterParams params = new ImageWriterParams(); params.setResolution((int)Math.round(src.getSize().getDpiHorizontal())); writer.writeImage(rendered.getRenderedImage(), baout, params); return new ImageRawStream(src.getInfo(), getTargetFlavor(), new java.io.ByteArrayInputStream(baout.toByteArray())); }
private void updateIntrinsicSize(AFPImageObjectInfo imageObjectInfo, AFPPaintingState paintingState, ImageSize targetSize) { //Update image object info imageObjectInfo.setDataHeightRes((int)Math.round( targetSize.getDpiHorizontal() * 10)); imageObjectInfo.setDataWidthRes((int)Math.round( targetSize.getDpiVertical() * 10)); imageObjectInfo.setDataHeight(targetSize.getHeightPx()); imageObjectInfo.setDataWidth(targetSize.getWidthPx()); // set object area info int resolution = paintingState.getResolution(); AFPObjectAreaInfo objectAreaInfo = imageObjectInfo.getObjectAreaInfo(); objectAreaInfo.setResolution(resolution); }
public static CxCy scale(ImageInfo imageInfo, double xEmu, double yEmu) { ImageSize size = imageInfo.getSize(); double iwEmu = toEmu(size.getWidthPx(), size.getDpiHorizontal()); double ihEmu = toEmu(size.getHeightPx(), size.getDpiVertical()); return scaleToFit(iwEmu, ihEmu, xEmu, yEmu); }
sx *= sourceResolution / info.getSize().getDpiHorizontal(); sy *= sourceResolution / info.getSize().getDpiVertical(); at.scale(sx, sy);
effIntrinsicSize.getDpiHorizontal() * 10)); imageObjectInfo.setDataWidthRes((int)Math.round( effIntrinsicSize.getDpiVertical() * 10));
public static void readPNGHeader(ImageInputStream inputStream, ImageSize size) throws IOException { SeekableStream seekStream = new ImageInputStreamSeekableStreamAdapter(inputStream) { public void close() throws IOException { } }; PNGImage pngImage = new PNGImage(seekStream); size.setSizeInPixels(pngImage.getWidth(), pngImage.getHeight()); double dpiHorz = size.getDpiHorizontal(); double dpiVert = size.getDpiVertical(); if (pngImage.unitSpecifier == 1) { if (pngImage.xPixelsPerUnit != 0) { dpiHorz = pngImage.xPixelsPerUnit * 0.0254; } if (pngImage.yPixelsPerUnit != 0) { dpiVert = pngImage.yPixelsPerUnit * 0.0254; } } size.setResolution(dpiHorz, dpiVert); size.calcSizeFromPixels(); } }
ditherSize.width, ditherSize.height, resolution); imageObjectInfo.setDataHeightRes((int)Math.round( ditherBitmapSize.getDpiHorizontal() * 10)); imageObjectInfo.setDataWidthRes((int)Math.round( ditherBitmapSize.getDpiVertical() * 10));
double sx = pos.getWidth() / info.getSize().getWidthMpt(); double sy = pos.getHeight() / info.getSize().getHeightMpt(); sx *= userAgent.getSourceResolution() / info.getSize().getDpiHorizontal(); sy *= userAgent.getSourceResolution() / info.getSize().getDpiVertical(); at.scale(sx, sy);
private void updateDataObjectInfo(AFPDataObjectInfo dataObjectInfo, ImageRawStream rawStream, AFPResourceManager resourceManager) throws IOException { dataObjectInfo.setMimeType(rawStream.getFlavor().getMimeType()); AFPResourceInfo resourceInfo = dataObjectInfo.getResourceInfo(); if (!resourceInfo.levelChanged()) { resourceInfo.setLevel(resourceManager.getResourceLevelDefaults() .getDefaultResourceLevel(ResourceObject.TYPE_IMAGE)); } InputStream inputStream = rawStream.createInputStream(); try { dataObjectInfo.setData(IOUtils.toByteArray(inputStream)); } finally { IOUtils.closeQuietly(inputStream); } int dataHeight = rawStream.getSize().getHeightPx(); dataObjectInfo.setDataHeight(dataHeight); int dataWidth = rawStream.getSize().getWidthPx(); dataObjectInfo.setDataWidth(dataWidth); ImageSize imageSize = rawStream.getSize(); dataObjectInfo.setDataHeightRes((int) (imageSize.getDpiHorizontal() * 10)); dataObjectInfo.setDataWidthRes((int) (imageSize.getDpiVertical() * 10)); }
int xdensity = in.readUnsignedShort(); int ydensity = in.readUnsignedShort(); if (size.getDpiHorizontal() == 0) { if (densityUnits == 2) { } else { if (size.getDpiHorizontal() == 0) { size.setResolution(context.getSourceResolution()); int width = in.readUnsignedShort(); size.setSizeInPixels(width, height); if (size.getDpiHorizontal() != 0) { size.calcSizeFromPixels(); return size; case EOI: if (size.getDpiHorizontal() == 0) { size.setResolution(context.getSourceResolution()); size.calcSizeFromPixels();