CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    4

    How Convert a Byte array to a image format

    --------------------------------------------------------------------------------

    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.

  2. #2
    Join Date
    May 2009
    Posts
    2,413

    Re: How Convert a Byte array to a image format

    Quote Originally Posted by perlWhite View Post
    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.

  3. #3
    Join Date
    Aug 2009
    Posts
    4

    Re: How Convert a Byte array to a image format

    its still not clear for me....can please explain with a code......

  4. #4
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: How Convert a Byte array to a image format

    You can create a ByteArrayInputStream from the byte array and then read the image from the input stream using the ImageIO class:
    Code:
    InputStream is = new ByteArrayInputStream(byteArray);
    BufferedImage image = ImageIO.read(is);
    Less is more...
    M. van der Rohe
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured