【问题标题】:converting bmp to jpg in java在java中将bmp转换为jpg
【发布时间】: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 小得多的图像,但不会损失图像质量。

标签: java jpeg bmp


【解决方案1】:

是的,你会的。实际上,无论将 BMP(无损)转换为 JPG(有损)的方式如何,您总是会丢失质量。如果将 JPG 质量设置为 100%,则可以限制损坏(在我看来,这与目的不符)。

使用此tutorial 修复它。

【讨论】:

    猜你喜欢
    • 2015-05-10
    • 2011-10-16
    • 2012-12-26
    • 2011-05-29
    • 2018-08-27
    • 2012-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多