在java中将bmp转换为jpg [英] converting bmp to jpg in java

查看:563
本文介绍了在java中将bmp转换为jpg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Java中将bmp转换为jpg?我知道如何使用 ImageIO 的方式,但有更快或更好的方法吗?

How do you convert bmp to jpg in Java? I know how to use the ImageIO way but is there a much faster or better way of doing it?

这个是我在网上找到的ImageIO方式。

This is the ImageIO way of doing that I found on the web.

`//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);

如果我使用这种方式,我会失去质量吗?

If I use this way will I lose quality?

谢谢

推荐答案

是的,你会的。实际上无论将BMP(无损)转换为JPG(有损)的方式如何,您总是会失去质量。如果您将JPG质量设置为100%(在我看来哪种方式违背了目的),您可以限制损坏。

Yes you will. Actually regardless of the way to convert a BMP (lossless) to JPG (lossy) you always lose quality. You can limit the damage if you set the JPG quality to 100% (which kind of defeats the purpose in my opinion).

使用此教程来修复它。

这篇关于在java中将bmp转换为jpg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆