Results 1 to 5 of 5
  1. #1
    Deva is offline Member
    Join Date
    Dec 2009
    Posts
    6
    Rep Power
    0

    Default Image to Binary bits

    Can any one guide me how to convert the image into binary bits and vice versa in JAVA.;)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,658
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Deva View Post
    Can any one guide me how to convert the image into binary bits and vice versa in JAVA.;)
    Read about the BufferedImage class; you can get/set individual pixel colours or do what you want with the values.

    kind regards,

    Jos

  3. #3
    Deva is offline Member
    Join Date
    Dec 2009
    Posts
    6
    Rep Power
    0

    Default Thanks

    Hi JosAH
    Thanks for your reply. Can you pls say me the functions that used for it.;

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,658
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Deva View Post
    Hi JosAH
    Thanks for your reply. Can you pls say me the functions that used for it.;
    You should download and install the entire API documentation and you'll know all. Google is your friend.

    kind regards,

    Jos

  5. #5
    raqman is offline Member
    Join Date
    Sep 2009
    Posts
    37
    Rep Power
    0

    Default

    I think you would have to create a PixelGrabber which returns an array of ints made from the image. Once you have that, I think you could use this method to convert the ints to binary:

    Integer.toBinaryString(int);

    Here is an example of a Pixel Grabber that creates a screen shot and throws it into an array of ints.

    private int[] capture() throws InterruptedException {
    dim = Toolkit.getDefaultToolkit().getScreenSize();
    Image tmp = robot.createScreenCapture(new Rectangle(dim.width,dim.height)).getScaledInstance
    (800,600,BufferedImage.SCALE_SMOOTH);
    int pix[] = new int[IMG_WIDTH*IMG_HEIGHT];
    PixelGrabber pg = new PixelGrabber
    (tmp,0,0,IMG_WIDTH,IMG_HEIGHT,pix,0,IMG_WIDTH);
    pg.grabPixels();
    return pix;
    }
    RAQ Report: free Java reporting tool.

Similar Threads

  1. How save Image BMP Binary type?
    By shakall in forum SWT / JFace
    Replies: 3
    Last Post: 12-22-2009, 01:50 PM
  2. extracting bits from big numbers
    By ankitmcgill in forum New To Java
    Replies: 6
    Last Post: 05-05-2009, 04:36 AM
  3. How to set the background of binary image?
    By hyz_zsu in forum Java 2D
    Replies: 1
    Last Post: 04-09-2009, 03:14 AM
  4. converting image to binary code n vice versa
    By nupurashi in forum Advanced Java
    Replies: 4
    Last Post: 04-01-2009, 07:27 PM
  5. Replies: 0
    Last Post: 01-08-2008, 05:29 PM

Posting Permissions

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