日期:2014-05-20  浏览次数:20679 次

java如何从字节数组显示gif图片?
RT,我用socket接收到一张gif图片的信息,放到了字节数组中,请问该怎么显示它呢?(不保存成文件,直接显示)

------解决方案--------------------

public BufferedImage getDecompressedImage(byte[] imageData) {
try {
ByteArrayInputStream bais = new ByteArrayInputStream(imageData);
return ImageIO.read(bais);
} catch (IOException ex) {
return null;
}
}
这里使用byte构造成一张图片,是在内存中的,直接画这个方法返回的图像