Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java中bmp到jpg的转换_Java_Jpeg_Bmp - Fatal编程技术网

java中bmp到jpg的转换

java中bmp到jpg的转换,java,jpeg,bmp,Java,Jpeg,Bmp,如何在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 t

如何在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);
如果我用这种方式,我会失去质量吗


谢谢

是的,你会的。实际上,无论以何种方式将BMP(无损)转换为JPG(有损),质量总是会下降。如果你将JPG的质量设置为100%,你可以限制伤害(我认为这与目的背道而驰)


用这个来修复它。

是的,你会的。实际上,无论以何种方式将BMP(无损)转换为JPG(有损),质量总是会下降。如果你将JPG的质量设置为100%,你可以限制伤害(我认为这与目的背道而驰)


用这个来修复它。

我建议使用PNG而不是JPG。你仍然会得到比BMP小得多的图像,但不会损失图像质量。我建议使用PNG而不是JPG。您仍然可以获得比BMP小得多的图像,但不会损失图像质量。