Click to See Complete Forum and Search --> : How Convert a Byte array to a image format


perlWhite
August 22nd, 2009, 12:13 PM
--------------------------------------------------------------------------------

Hi,
How to convert a Byte array to an image format....I shall be more about my question and what i want...See i recieve a Byte array fom server this Byte array before recieveing at my end it was converted from an image/text format into a Byte array and is sent from server and, I recieve this Byte array now I have to convert this Byte array into their respective image....please tell me how to convert a Byte array to a image ......... Kindly explain clearly as i am new to Java......

Thanking You.

nuzzle
August 22nd, 2009, 07:36 PM
How to convert a Byte array to an image format....

It's very simple really. You know what the byte array holds and you convert it to a new byte array holding what it's been converted to.

This requires knowledge of what you have and what you want. You convert data of one type to data of another type. That's all there's to it really.

perlWhite
August 22nd, 2009, 11:10 PM
its still not clear for me....can please explain with a code......

dlorde
August 23rd, 2009, 04:28 AM
You can create a ByteArrayInputStream from the byte array and then read the image from the input stream using the ImageIO class:InputStream is = new ByteArrayInputStream(byteArray);
BufferedImage image = ImageIO.read(is);Less is more...
M. van der Rohe