}
} www.2cto.com
AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(ratio, ratio), null);
Image newImage = op.filter(bi, null);
try {
//如果目录不存在,则创建
//File newPathDir=new File(newPath.substring(0,newPath.lastIndexOf("\\")+1));
//if(!newPathDir.exists()) newPathDir.mkdirs();
ImageIO.write((BufferedImage) newImage, newFileType, new File(newPath));
} catch (IOException e) {
// TODO Auto-generated catch block
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
摘自 那年那月那天