Java examples for 2D Graphics:BufferedImage Scale
scale Image
//package com.java2s; import java.awt.Image; import java.awt.image.BufferedImage; public class Main { public static BufferedImage scaleImage(BufferedImage image, double xscale, double yscale) { int width = (int) ((double) (image.getWidth()) * xscale); int height = (int) ((double) (image.getHeight()) * yscale); width = Math.max(1, width); height = Math.max(1, height); Image newImage = image.getScaledInstance(width, height, Image.SCALE_FAST); BufferedImage newBuffered = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); newBuffered.getGraphics().drawImage(newImage, 0, 0, null); return newBuffered; }/*from www. j a v a2 s.c o m*/ }