size.setBaselinePositionFromBottom((int) (icon.getTrueIconDepth() * 1000)); size.setResolution(context.getSourceResolution()); size.calcPixelsFromSize(); info.setSize(size);
size.calcPixelsFromSize(); info.setSize(size);
private void paintCornersAsBitmap(Graphics2DImagePainter painter, Rectangle boundingBox, String name) throws IFException { //TODO parameters ok? ImageInfo info = new ImageInfo(name, null); ImageSize size = new ImageSize(); size.setSizeInMillipoints(boundingBox.width, boundingBox.height); //Use the foreign attributes map to set image handling hints Map map = new java.util.HashMap(2); map.put(AFPForeignAttributeReader.RESOURCE_NAME, name); map.put(AFPForeignAttributeReader.RESOURCE_LEVEL, "print-file"); AFPRenderingContext context = (AFPRenderingContext) this.painter.createRenderingContext(/*map*/); size.setResolution(context.getPaintingState().getResolution()); size.calcPixelsFromSize(); info.setSize(size); ImageGraphics2D img = new ImageGraphics2D(info, painter); Map hints = new java.util.HashMap(); hints.put(ImageHandlerUtil.CONVERSION_MODE, ImageHandlerUtil.CONVERSION_MODE_BITMAP); hints.put("TARGET_RESOLUTION", context.getPaintingState().getResolution()); try { this.painter.drawImage(img, boundingBox, context, true, hints); } catch (IOException ioe) { throw new IFException( "I/O error while painting corner using a bitmap", ioe); } catch (ImageException ie) { throw new IFException( "Image error while painting corner using a bitmap", ie); } }
(int)Math.round(bbox.getHeight() * 1000)); size.setResolution(context.getSourceResolution()); size.calcPixelsFromSize(); info.setSize(size); info.getCustomObjects().put(EPS_BOUNDING_BOX, bbox);
private ImageSize determineSize(ImageInputStream in, ImageContext context) throws IOException, ImageException { in.mark(); ByteOrder oldByteOrder = in.getByteOrder(); try { ImageSize size = new ImageSize(); // BMP uses little endian notation! in.setByteOrder(ByteOrder.LITTLE_ENDIAN); //resolution in.skipBytes(WIDTH_OFFSET); int width = (int)in.readUnsignedInt(); int height = (int)in.readUnsignedInt(); in.skipBytes(HRES_PIXEL_OFFSET - WIDTH_OFFSET - 8); long hresPixel = in.readUnsignedInt(); long vresPixel = in.readUnsignedInt(); long hresMM = in.readUnsignedInt(); long vresMM = in.readUnsignedInt(); double resHorz = hresPixel / UnitConv.mm2in(hresMM); double resVert = vresPixel / UnitConv.mm2in(vresMM); size.setResolution(resHorz, resVert); width = (int)Math.round(UnitConv.mm2mpt(width / 100f)); height = (int)Math.round(UnitConv.mm2mpt(height / 100f)); size.setSizeInMillipoints(width, height); size.calcPixelsFromSize(); return size; } finally { in.setByteOrder(oldByteOrder); in.reset(); } }
(int)Math.round(intrinsicDimensions.getX() * 1000), (int)Math.round(intrinsicDimensions.getY() * 1000)); size.calcPixelsFromSize(); info.setSize(size);