Results 1 to 6 of 6
  1. #1
    Mantra is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default Image file to binary file conversion

    Hello.
    I want to convert any image file to binary file.
    How can I do it?
    please help.
    Thank You!!

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    An "image" file is a "binary" file. Now what is it you actually want to know?

  3. #3
    Mantra is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    Okay.. Thats right.. But I would like to convert the image file for example, An jpeg file into form of file containing 1 and 0. in other words, i want to see the binary representation of that original file as an input.

  4. #4
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    So use an FileInputStream and read it byte by byte and use the Integer.toBinaryString method to create the binary representation of that byte (don't forget to left pad zeros to a length of 8 for each and every byte) and then write that back into another file.

  5. #5
    Mantra is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    Thank you.
    your reply looks promising. But I am quite new to java, so i am looking into it.
    But if u can help me in further detail, that would be of great help to me.

  6. #6
    Mantra is offline Member
    Join Date
    Nov 2010
    Posts
    4
    Rep Power
    0

    Default

    Alright.. Now i have managed to read the image using fileinputstream ... And stored it in byte array. now how can I proceed with the byte array?

Similar Threads

  1. Image file to Text Conversion
    By sureshsoftengg in forum New To Java
    Replies: 2
    Last Post: 09-21-2010, 12:08 PM
  2. Replies: 3
    Last Post: 05-09-2009, 11:31 PM
  3. Conversion of image object into file
    By aartheesrini in forum Java Applets
    Replies: 0
    Last Post: 03-12-2009, 08:09 AM
  4. image to byte code file conversion
    By nupurashi in forum Java Tip
    Replies: 0
    Last Post: 01-28-2009, 10:25 AM
  5. Regarding conversion of Image file to Video file
    By RamaDeviMsc in forum Advanced Java
    Replies: 0
    Last Post: 06-25-2007, 02:28 PM

Tags for this Thread

Posting Permissions

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