【发布时间】:2012-05-31 16:09:24
【问题描述】:
如何在 Java 中将 bmp 转换为 jpg?我知道如何使用 ImageIO 方式,但有更快或更好的方式吗?
这是我在网上找到的 ImageIO 方法。
`//Create file for the source
File input = new File("c:/temp/image.bmp");
//Read the file to a BufferedImage
BufferedImage image = ImageIO.read(input);`
//Create a file for the output
File output = new File("c:/temp/image.jpg");
//Write the image to the destination as a JPG
ImageIO.write(image, "jpg", output);
如果我用这种方式会失去质量吗?
谢谢
【问题讨论】:
-
我建议使用 PNG 而不是 JPG。您仍然可以获得比 BMP 小得多的图像,但不会损失图像质量。