ImageIO.write(new ScaleFilter(100,100), "jpeg", dest);
//源代码片段来自云代码http://yuncode.net
public class ScaleFilter extends AbstractBufferedImageOp {
private int width;
private int height;
/**
* Construct a ScaleFilter.
*/
public ScaleFilter() {
this(32, 32);
}
/**
* Construct a ScaleFilter.
* @param width the width to scale to
* @param height the height to scale to
*/
public ScaleFilter( int width, int height ) {
this.width = width;
this.height = height;
}
if ( dst == null ) {
dst
= new BufferedImage(dstCM, dstCM.
createCompatibleWritableRaster( width, height
),
dstCM.isAlphaPremultiplied(), null);
}
Image scaleImage
= src.
getScaledInstance( width, height,
Image.
SCALE_AREA_AVERAGING );
g.drawImage( scaleImage, 0, 0, width, height, null );
g.dispose();
return dst;
}
return "Distort/Scale";
}
}//源代码片段来自云代码http://yuncode.net