I need to decode a message from the top line of pixels in a BMP picture. There is a message hidden in the red value in binary. I have tried finding a way to do this and haven't succeeded because most programs use .jpg or .png file types for images and BMP images don't work in that code. I need to find out how to reverse this code to decode the message using arrays, and I need to print the message in ASCII text. For some programs, they allowed to me array the top line of the image but I don't know how to print it. Here is the code for encoding the message in the image:
import java.awt.*;
class Encode
{
public void encodeMessage(Picture image, int [] binaryArray)
{
Pixel pixelTarget = new Pixel(image,0,0);
Pixel [] pixelArray = image.getPixels();
Color pixelColor = null;
int redValue = 0;
for(int x = 0; x < binaryArray.length; x++)
{
redValue = binaryArray[x];
pixelTarget = pixelArray[x];
pixelTarget.setRed(redValue);
}
pixelTarget = pixelArray[binaryArray.length];
pixelTarget.setRed(255);
image.write("SecretMessage.bmp");
image.explore();
}
}
public class EncodeTester
{
public static void main(String[] args)
{
int[] bitArray = {0,1,1,0,0,0,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,1,1,0,0,1,1,0,0,0,0,1,0,1,1,1,0,0,1,0,0,1,1,1,1,0,0,1};
Picture image = new Picture("earth.bmp");
Encode message = new Encode();
message.encodeMessage(image, bitArray);
}
}
Could someone please explain how to continue or write up a sample code for me to read the bmp file, get the red values from arrays and print it out in ASCII text. Thanks
EDIT: This isn't exactly steganograhpy. It is different as the code is hidden only in the first line and I need to use int[] arrays to array all pixels, then array the top line of pixels, then print out the red values in ASCII text.