当前位置: 代码迷 >> J2SE >> java怎么从字节数组显示gif图片
  详细解决方案

java怎么从字节数组显示gif图片

热度:199   发布时间:2016-04-24 01:31:28.0
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构造成一张图片,是在内存中的,直接画这个方法返回的图像
  相关解决方案