List of usage examples for java.awt Image SCALE_AREA_AVERAGING
int SCALE_AREA_AVERAGING
To view the source code for java.awt Image SCALE_AREA_AVERAGING.
Click Source Link
From source file:ucar.unidata.idv.ui.ImageGenerator.java
/** * Resize the image//from ww w . ja v a 2s . c o m * * @param image The image * @param node Node to process. This may contain a width or a height attribute. * * @return The resized image */ protected Image resize(Image image, Element node) { int imageWidth = image.getWidth(null); int imageHeight = image.getHeight(null); int width = -1; int height = -1; if (XmlUtil.hasAttribute(node, ATTR_WIDTH)) { width = (int) toDouble(node, ATTR_WIDTH, imageWidth); } if (XmlUtil.hasAttribute(node, ATTR_HEIGHT)) { height = (int) toDouble(node, ATTR_HEIGHT, imageWidth); } if ((width == -1) && (height == -1)) { return image; } return image.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING); }
From source file:ucar.unidata.idv.ui.ImageGenerator.java
/** * Resize the image//from ww w .j a va2 s. co m * * @param image The image * @param widthStr width of desired image (pixels) * @param heightStr height of desired image (pixels) * * @return The resized image */ public BufferedImage resizeImage(BufferedImage image, String widthStr, String heightStr) { int imageWidth = image.getWidth(null); int imageHeight = image.getHeight(null); int width = -1; int height = -1; if (!widthStr.equals("-1")) { width = (int) toDouble(widthStr, imageWidth); } if (!heightStr.equals("-1")) { height = (int) toDouble(heightStr, imageHeight); } if ((width == -1) && (height == -1)) { return image; } BufferedImage resizedImage = ImageUtils.toBufferedImage( image.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING), BufferedImage.TYPE_INT_RGB); return resizedImage; }