ImageIO.write不能另存为gif,但适用于jpg和png? [英] ImageIO.write not saving out as gif, but works for jpgs and pngs?
本文介绍了ImageIO.write不能另存为gif,但适用于jpg和png?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怀疑这里的解决方案可能真的很简单,但是我很困惑...
I suspect the solution here is probably really simple, but I'm stumped...
// Create the buffered image.
BufferedImage bufferedImage = new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB);
// fill image data (works fine)
ImageIO.write(bufferedImage, "JPG", f1); // works fine
ImageIO.write(bufferedImage, "PNG", f2); // works fine
ImageIO.write(bufferedImage, "GIF", f3); // this returns false, creates a broken gif file, but fires no exceptions
ImageIO.write()
不能用于gif吗?这是对gif作为Compuserve专有的东西吗?还是我只是愚蠢(我猜这是最后一个了:))
Does ImageIO.write()
not work for gifs? is this some sort of throwback to gif being a proprietary Compuserve thing? Or am I just being stupid (I'm guessing it's the last one :) )
推荐答案
Note that GIF can only store 256 colors.
这篇关于ImageIO.write不能另存为gif,但适用于jpg和png?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文