File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes BufferedImage from byte[] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "BufferedImage from byte[]" Watch "BufferedImage from byte[]" New topic

BufferedImage from byte[]

sanket karkare

Joined: Jan 12, 2009
Posts: 10
I have a byte array.
How can I construct a BufferedImage object.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
You could use one of the BufferedImage constructors, then call its getWriteableRaster method, and then use one of its setPixel methods appropriately.

Do you know how the bytes are arranged in the byte[]? Meaning, in which order the Red, Green, Blue and transparency values are arranged (assuming it has those), and the width and height of the image?
sanket karkare

Joined: Jan 12, 2009
Posts: 10
Thanks, problem solved
I agree. Here's the link:
subject: BufferedImage from byte[]
It's not a secret anymore!