所以我尝试使用以下代码调整.bmp图像的大小:
void resizeSeenAreaToFitRetina(String BMPImageFileName, int newWidth, int newHeight) throws IOException {
BufferedImage bmpImage = ImageIO.read(getClass().getResource(BMPImageFileName));
Image scaledBMPImage = bmpImage.getScaledInstance(newWidth, newHeight, Image.SCALE_FAST);
BufferedImage scaledBufferedBMPImage = (BufferedImage) scaledBMPImage; // I know I can't do this but ImageIO.write(only_takes_BufferedImage_class_here, ...)
ImageIO.write(scaledBufferedBMPImage, "bmp", new File("ResizedArray2DTest.bmp"));
}
如何将已调整大小的图像写入文件?
答案 0 :(得分:1)
我希望这些链接可以帮助您:
http://www.mkyong.com/java/how-to-resize-an-image-in-java/
http://www.mkyong.com/java/how-to-write-an-image-to-file-imageio/
答案 1 :(得分:0)