Example usage for java.awt RenderingHints get

List of usage examples for java.awt RenderingHints get

Introduction

In this page you can find the example usage for java.awt RenderingHints get.

Prototype

public Object get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped.

Usage

From source file:com.alibaba.simpleimage.util.ImageUtils.java

public static ImageLayout getImageLayoutHint(RenderingHints renderHints) {
    if (renderHints == null) {
        return null;
    } else {/*w w  w. ja v a2 s  .c o  m*/
        return (ImageLayout) renderHints.get(JAI.KEY_IMAGE_LAYOUT);
    }
}

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  .  j a  v a  2 s . 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;
}