Here you can find the source of resampleWithAffineTransformOp(BufferedImage srcImage, double sx, double sy)
public static final BufferedImage resampleWithAffineTransformOp(BufferedImage srcImage, double sx, double sy)
//package com.java2s; import java.awt.image.BufferedImage; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; public class Main { public static final BufferedImage resampleWithAffineTransformOp(BufferedImage srcImage, double sx, double sy) { //System.err.println("BufferedImageUtilities.resampleWithAffineTransformOp(): start"); //long startTime = System.currentTimeMillis(); AffineTransform transform = AffineTransform.getScaleInstance(sx, sy); AffineTransformOp transformOp = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); BufferedImage dstImage = transformOp.createCompatibleDestImage(srcImage, srcImage.getColorModel()); // otherwise returns, say RGBA even if gray dstImage = transformOp.filter(srcImage, dstImage); //System.err.println("BufferedImageUtilities.resampleWithAffineTransformOp() elapsed: "+(System.currentTimeMillis()-startTime)+" ms"); return dstImage; }//from w w w . j a v a 2 s. c o m public static final BufferedImage resampleWithAffineTransformOp(BufferedImage srcImage, int dstWidth, int dstHeight) { //System.err.println("BufferedImageUtilities.resampleWithAffineTransformOp():"); int srcWidth = srcImage.getWidth(); int srcHeight = srcImage.getHeight(); double sx = ((double) dstWidth) / srcWidth; double sy = ((double) dstHeight) / srcHeight; return resampleWithAffineTransformOp(srcImage, sx, sy); } }