Post: Print Red Binary Values to Script from An Image
08-02-2016, 04:39 PM #1
DMoney750
ERROR ON THE INTERNETZ!!!
(adsbygoogle = window.adsbygoogle || []).push({}); Hey guys I need to convert red values from a BMP image. I have tried to find an answer to my question, but could not find one that I could understand. I just need to convert the red values at the top of the line on an image, and print them to display the text. Here's the code:
    import java.awt.*;
class HideMessage
{
public void encodeMessage(Picture stegoObject, int [] binaryArray)
{
Pixel pixelTarget = new Pixel(stegoObject,0,0);
Pixel [] pixelArray = stegoObject.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);

stegoObject.write("SecretMessage.bmp");
stegoObject.explore();

}

}
public class HideMessageTester
{
public static void main(String[] args)
{
int[] bitArray = {0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,1,0};

Picture stegoObject = new Picture("earth.bmp");
HideMessage stego = new HideMessage();

stego.encodeMessage(stegoObject, bitArray);

}
}


I know that the message is: Java. But I need a way to show how to convert the red values into that text. Please help!
08-02-2016, 06:13 PM #2
Jim Halpert
Bounty hunter
Originally posted by DMoney750 View Post
Hey guys I need to convert red values from a BMP image. I have tried to find an answer to my question, but could not find one that I could understand. I just need to convert the red values at the top of the line on an image, and print them to display the text. Here's the code:
    import java.awt.*;
class HideMessage
{
public void encodeMessage(Picture stegoObject, int [] binaryArray)
{
Pixel pixelTarget = new Pixel(stegoObject,0,0);
Pixel [] pixelArray = stegoObject.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);

stegoObject.write("SecretMessage.bmp");
stegoObject.explore();

}

}
public class HideMessageTester
{
public static void main(String[] args)
{
int[] bitArray = {0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,1,0};

Picture stegoObject = new Picture("earth.bmp");
HideMessage stego = new HideMessage();

stego.encodeMessage(stegoObject, bitArray);

}
}


I know that the message is: Java. But I need a way to show how to convert the red values into that text. Please help!


What are red values?
08-02-2016, 06:21 PM #3
DMoney750
ERROR ON THE INTERNETZ!!!
Originally posted by Jim
What are red values?


They can be found in the array "bitArray"
08-02-2016, 07:19 PM #4
Jim Halpert
Bounty hunter
Originally posted by DMoney750 View Post
They can be found in the array "bitArray"


It's not very clear to me what you are asking.
08-02-2016, 07:40 PM #5
DMoney750
ERROR ON THE INTERNETZ!!!
Originally posted by Jim
It's not very clear to me what you are asking.


I want to convert those binary values to decimal values, and then convert the decimal values to a string. The red binary values are placed in an image and its hidden. I want to take those binary values from the image and, as I said, convert them into decimal values, and then cover the decimal values to a string. Then, I want to print the string, which should say, "Java".
08-03-2016, 12:04 AM #6
Toxic
former staff
Originally posted by DMoney750 View Post
I want to convert those binary values to decimal values, and then convert the decimal values to a string. The red binary values are placed in an image and its hidden. I want to take those binary values from the image and, as I said, convert them into decimal values, and then cover the decimal values to a string. Then, I want to print the string, which should say, "Java".


i guess you're referring to cryptography?
08-03-2016, 04:52 AM #7
Jim Halpert
Bounty hunter
Originally posted by DMoney750 View Post
I want to convert those binary values to decimal values, and then convert the decimal values to a string. The red binary values are placed in an image and its hidden. I want to take those binary values from the image and, as I said, convert them into decimal values, and then cover the decimal values to a string. Then, I want to print the string, which should say, "Java".


I understand now. Well, 0100101001100001011101100110000100001010 is a huge number. This cannot possibly be converted to any integral type (unless you find some crazy number library). An unsigned long long (uint64_t) can hold the largest integer, being 18446744073709551615. That's still not as big as your binary number.
08-03-2016, 05:29 PM #8
Originally posted by Jim
I understand now. Well, 0100101001100001011101100110000100001010 is a huge number. This cannot possibly be converted to any integral type (unless you find some crazy number library). An unsigned long long (uint64_t) can hold the largest integer, being 18446744073709551615. That's still not as big as your binary number.


What? It's binary, of course it's going to be huge...
Not sure how you do it in Java, but in C# you can simply do:
    
string bits = "0100101001100001011101100110000100001010";
int number = Convert.ToInt32(bits, 2);


That will convert it to a integer, I'm sure it's the same concept for converting to a decimal.

EDIT:

Originally posted by DMoney750 View Post
Hey guys I need to convert red values from a BMP image. I have tried to find an answer to my question, but could not find one that I could understand. I just need to convert the red values at the top of the line on an image, and print them to display the text. Here's the code:
    import java.awt.*;
class HideMessage
{
public void encodeMessage(Picture stegoObject, int [] binaryArray)
{
Pixel pixelTarget = new Pixel(stegoObject,0,0);
Pixel [] pixelArray = stegoObject.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);

stegoObject.write("SecretMessage.bmp");
stegoObject.explore();

}

}
public class HideMessageTester
{
public static void main(String[] args)
{
int[] bitArray = {0,1,0,0,1,0,1,0,0,1,1,0,0,0,0,1,0,1,1,1,0,1,1,0,0,1,1,0,0,0,0,1,0,0,0,0,1,0,1,0};

Picture stegoObject = new Picture("earth.bmp");
HideMessage stego = new HideMessage();

stego.encodeMessage(stegoObject, bitArray);

}
}


I know that the message is: Java. But I need a way to show how to convert the red values into that text. Please help!


I now understand your question, so the first thing you'll have to do is convert your binary int array into a string. After that use 'Integer.parseInt' to convert it to a integer/decimal. Then after it's a decimal just convert it to hexadecimal to display 'Java.'.

Here is some pseudocode you can use:
    
String bits = "0100101001100001011101100110000100001010";
String decimalVal = Integer.parseInt(bits, 2).toString();


The string 'decimalVal' will now hold the decimal, but you'll have to use a function to convert it into hex. I'm not too familiar with Java, but it can be feasible.
Last edited by Red-EyeX32 ; 08-03-2016 at 05:47 PM.

The following user thanked Red-EyeX32 for this useful post:

DMoney750

Copyright © 2025, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo