开发者

How do I convert byte[] to Bitmap?

Let's say I have a byte buffe开发者_StackOverflow社区r and how do I get Bitmap?


If you want to manipulate the image, use ImageIO. It creates a format-agnostic image in memory:

BufferedImage img = ImageIO.read(new ByteArrayInputStream(bytes));

If you just want to store in to disk, then simply write the byte array to a file.

Note that the byte array must be already a bitmap image, you can't take any byte array and have it as bitmap.

And you get the byte array from the byte buffer by:

byte[] bytes = new byte[buf.capacity()];
buf.get(bytes, 0, bytes.length);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜