缓冲图像大小调整
2022-08-31 20:08:43
我正在尝试调整缓冲区图像的大小。我能够存储它并显示在jframe上没有问题,但我似乎无法调整它的大小。关于如何更改它以使其工作并将图像显示为200 * 200文件的任何提示都将很棒
private void profPic(){
String path = factory.getString("bottle");
BufferedImage img = ImageIO.read(new File(path));
}
public static BufferedImage resize(BufferedImage img, int newW, int newH) {
int w = img.getWidth();
int h = img.getHeight();
BufferedImage dimg = new BufferedImage(newW, newH, img.getType());
Graphics2D g = dimg.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(img, 0, 0, newW, newH, 0, 0, w, h, null);
g.dispose();
return dimg;
}