第一步:读入文件
public BufferedImage loadImageLocal(String path) {
try {
return ImageIO.read(new File(path));
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
第二步:缩放文件
/**
*
* @param mini 贴图
* @param Scale 缩放比例
* @return
*/
public BufferedImage modifyImageScale(BufferedImage mini,double Scale) {
int w = (int)Math.round(mini.getWidth()*Scale);
int h = (int)Math.round(mini.getHeight()*Scale);
//设置生成图片宽*高,色彩
BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
//创建画布
Graphics2D g2 = bi.createGraphics();
//设置图片透明 注********:只有png格式的图片才能设置背景透明,jpg设置图片颜色变的乱七八糟
bi = g2.getDeviceConfiguration().createCompatibleImage(w