【发布时间】:2015-12-19 10:08:31
【问题描述】:
我不知道为什么这种方法不能调整图像大小。没有错误发生(如果有,我有一个例外):
private static void resizeImage(int width, int height) {
try {
BufferedImage rawImg = ImageIO.read(new File("%imgg%.png"));
int gamlaWidth = rawImg.getWidth();
int gamlaHeight = rawImg.getHeight();
BufferedImage dimg = new BufferedImage(width, height, rawImg.getType());
Graphics2D g = rawImg.createGraphics();
g.drawImage(rawImg, 0, 0, 114, 114, null);
g.dispose();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Ett fel uppstod:\n" + e, "Felmeddelande", 0);
}
}
为什么这段代码没有改变任何东西?我希望大小为 114x114。
【问题讨论】: