可以将BufferedImage写入任何格式的文件吗? [英] Can a BufferedImage be written to file any format?
问题描述
如果我们在java中有一个BufferedImage对象,我们可以使用ImageIO.write以任何格式写出来(如果我们有一个Writer对象),这是正确的吗?我尝试将一个BufferedImage对象写入jpg文件,它输出一个空的图像文件,但是当我尝试将其写入png文件时,它工作正常。
Is it correct that if we have a BufferedImage object in java, we could potentially write it out in ANY format using ImageIO.write (if we have a Writer object for the same)? I tried writing a BufferedImage object into a jpg file, it outputted an empty image file however when i tried writing it in to a png file, it worked fine.
推荐答案
BufferedImage可以写入ImageIO.write支持的任何格式(也就是说,有一个ImageWriter),是的。如果你不能让它工作,请出示代码。
A BufferedImage can be written into any format that ImageIO.write supports (that is, has an ImageWriter available), yes. Please show the code if you can't get it to work.
这篇关于可以将BufferedImage写入任何格式的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!