public static void decodeThis(BufferedImage im){
int w = im.getWidth();
int h=im.getHeight();
int[] arr=im.getRGB(0, 0, w, h, null, 0, w);
int[] eightBit=new int[8];
for (int i=0;i<arr.length;i++){
System.out.printf("%x \n",arr[i]);
}
}
So this is my code so far. I am confused as to how to read off the least-significant bit from each pixel from arr and storing it in eightBit. I just learned about arrays and BufferedImage so this is all pretty new to me – any help would be appreciated. Thanks!
I guess you are familiar with the whole concept of what lsb (least-significant bit) is since you don’t ask about that..?
What you need to do is to use bitwise and. That is the & operator (note: not &&). If you do ‘int i & 1’ you will get one if lsb of i is one and zero if its zero. Try playing around and reading avout bitwise operators and you will get the hang of it! Just comment if you wonder about something…