List of usage examples for java.awt RenderingHints put
public Object put(Object key, Object value)
From source file:util.ImgJaiTool.java
/** * A helper method that adds the tile cache hint with JAI.KEY_IMAGE_LAYOUT * to improve scale performance. This reduces the tile cache used to scale * the image./*from w w w .ja v a 2s. co m*/ * * warning... seems to slow things down in some cases. * * http://archives.java.sun.com/cgi-bin/wa?A2=ind0202&L=jai-interest&P=3228 * * @param hints * existing list of RenderingHints * @param image * image to scale * @param factX * scaling factor x * @param factY * scaling factor y */ protected static RenderingHints addScaleTileCacheHint(RenderingHints hints, RenderedOp image, float factX, float factY) { int tW = (int) (image.getTileWidth() * factX); int tH = (int) (image.getTileHeight() * factY); if (tW <= 0) { tW = 1; } if (tH <= 0) { tH = 1; } ImageLayout il = null; if (hints == null) { il = new ImageLayout().setTileWidth(tW).setTileHeight(tH); hints = new RenderingHints(JAI.KEY_IMAGE_LAYOUT, il); } else { il = (ImageLayout) hints.get(JAI.KEY_IMAGE_LAYOUT); if (il == null) { il = new ImageLayout(); } il.setTileWidth(tW).setTileHeight(tH); hints.put(JAI.KEY_IMAGE_LAYOUT, il); } return hints; }