Hi,
Can any one post the code for converting the image into binary bits and binary bits into image which i ve to store in the array for manipulating those bits. Kindly post me the complete code or send the URL that contains the code.
Regards,
Deva.
Printable View
Hi,
Can any one post the code for converting the image into binary bits and binary bits into image which i ve to store in the array for manipulating those bits. Kindly post me the complete code or send the URL that contains the code.
Regards,
Deva.
This thread is duplicated.
http://www.java-forums.org/new-java/...nary-bits.html
We usually help everybody. But it's not usual to give the complete code. JosAH sent to you the documentation needed to do what you want, please read it and you will be able to do it by yourself =)
Rgs.
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;
}