图片缩略图的实现,比较灵活[可直接使用] (二)

2014-11-24 03:29:10 · 作者: · 浏览: 1
ble)newHeight / originalHeight;
}
} 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
e.printStackTrace();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

摘自 那年那月那天