![]() |
|
[Release/Source] ImageSteg - hide one image in another - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: [Release/Source] ImageSteg - hide one image in another (/Thread-Release-Source-ImageSteg-hide-one-image-in-another) Pages:
1
2
|
[Release/Source] ImageSteg - hide one image in another - Deque - 11-04-2012 Hello HC. This is steganography program. It uses the last 2-4 bits of every pixelcolor to save one image in another. Because the information is in the least significant bits you can't see the hidden image with the eye. Of course the image quality suffers since some bits are lost in both pictures. Depending on the quality you choose in the program either the hidden image looks good and the image you see looks bad (good quality setting) or the other way around (bad quality setting). Once you have prepared an image, you can reveal the hidden image again. You have to choose the same quality option for extraction that has done the hiding, otherwise you will get whoosh. Screenshot: ![]() It also has a CLI which is used if you give parameters (no parameters = GUI): Quote:SYNOPSIS: The main algorithm (excerpt): Code: package control;
import gui.MainFrame;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import javax.swing.SwingUtilities;
public class ImageSteno {
public static final int ALPHA = 0;
public static final int RED = 1;
public static final int GREEN = 2;
public static final int BLUE = 3;
private BufferedImage mask;
private BufferedImage toHide;
private BufferedImage toExtract;
private Quality quality = Quality.GOOD;
public static void main(String[] args) throws IOException {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
new MainFrame();
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
public void setQuality(Quality quality) {
this.quality = quality;
}
public BufferedImage extractHiddenImage() throws NoImageException {
if (toExtract == null) {
throw new NoImageException();
}
return extractHiddenImage(toExtract);
}
public BufferedImage extractHiddenImage(BufferedImage img) {
BufferedImage imgCopy = copyImage(img);
for (int x = 0; x < imgCopy.getWidth(); x++) {
for (int y = 0; y < imgCopy.getHeight(); y++) {
int rgb = imgCopy.getRGB(x, y);
rgb = extractRGB(rgb);
imgCopy.setRGB(x, y, rgb);
}
}
return imgCopy;
}
public static BufferedImage copyImage(BufferedImage image) {
BufferedImage destImage = new BufferedImage(image.getWidth(),
image.getHeight(), BufferedImage.TYPE_INT_ARGB);
Graphics2D g = destImage.createGraphics();
g.drawImage(image, null, 0, 0);
g.dispose();
return destImage;
}
public BufferedImage hideImage() throws NoImageException {
if (mask == null || toHide == null) {
throw new NoImageException();
}
BufferedImage maskCopy = getScaledInstance(copyImage(mask),
toHide.getWidth(), toHide.getHeight(),
RenderingHints.VALUE_INTERPOLATION_BICUBIC, false);
for (int x = 0; x < toHide.getWidth(); x++) {
for (int y = 0; y < toHide.getHeight(); y++) {
int destRGB = toHide.getRGB(x, y);
int oldRGB = maskCopy.getRGB(x, y);
int newRGB = computeNewRGB(oldRGB, destRGB);
maskCopy.setRGB(x, y, newRGB);
}
}
return maskCopy;
}
private int extractRGB(int rgb) {
int[] rgbArr = getRGBArray(rgb);
for (int i = 1; i <= 3; i++) {
rgbArr[i] = rgbArr[i] & quality.leastBitsSum;
rgbArr[i] = rgbArr[i] << quality.shift;
}
return getRGBFromArray(rgbArr);
}
private int computeNewRGB(int oldRGB, int destRGB) {
int[] dest = getRGBArray(destRGB);
int[] old = getRGBArray(oldRGB);
for (int i = 1; i <= 3; i++) {
old[i] = old[i] & quality.cuttingMask;
dest[i] = dest[i] >> quality.shift;
old[i] += dest[i];
}
return getRGBFromArray(old);
}
private int getRGBFromArray(int[] rgbArr) {
return new Color(rgbArr[RED], rgbArr[GREEN], rgbArr[BLUE]).getRGB();
}
private int[] getRGBArray(int rgb) {
return new int[] { (rgb >> 24) & 0xff, (rgb >> 16) & 0xff,
(rgb >> & 0xff, rgb & 0xff };
}
}
public enum Quality {
GOOD(4), MEDIUM(3), BAD(2);
public int leastBitsSum;
public int shift;
public int cuttingMask;
private Quality(int bits){
computeLeastBitsSum(bits);
computeCuttingMask(bits);
computeShift(bits);
}
private void computeShift(int bits) {
shift = 8 - bits;
}
private void computeLeastBitsSum(int bits) {
leastBitsSum = 0;
for(int i = 0; i < bits; i++){
leastBitsSum += Math.pow(2, i);
}
}
private void computeCuttingMask(int bits) {
cuttingMask = 255 - leastBitsSum;
}
}LOC: 1029 without empty lines and comments 1273 with empty lines and comments Download: http://www.file-upload.net/download-6772568/ImageSteg.zip.html Have fun. Deque RE: [Release/Source] ImageSteg - hide one image in another - Solixious - 11-08-2012 It says could not find the main class when I tried to execute the jar file... RE: [Release/Source] ImageSteg - hide one image in another - Deque - 11-08-2012 That is weird. It works for me on Win 7 and Linux. Which Java version and OS do you use? How exactly did you run it (if via CLI, what did you type in)? RE: [Release/Source] ImageSteg - hide one image in another - FunKx - 11-08-2012 Umm. One question. Why would you want to hide an image in image? Ridiculous. RE: [Release/Source] ImageSteg - hide one image in another - chmod - 11-08-2012 Not at all there are plenty of reasons why you would do it RE: [Release/Source] ImageSteg - hide one image in another - FunKx - 11-08-2012 (11-08-2012, 01:04 PM)chmod Wrote: Not at all there are plenty of reasons why you would do it Be so kind name some or at least one. Just curious. RE: [Release/Source] ImageSteg - hide one image in another - Deque - 11-08-2012 (11-08-2012, 12:54 PM)FunKx Wrote: Umm. One question. Why would you want to hide an image in image? Ridiculous. You really ask me, why people want to hide information? I am pretty sure you can answer this to yourself if you think about it. RE: [Release/Source] ImageSteg - hide one image in another - FunKx - 11-08-2012 (11-08-2012, 01:09 PM)Deque Wrote:(11-08-2012, 12:54 PM)FunKx Wrote: Umm. One question. Why would you want to hide an image in image? Ridiculous. Hiding an image, in image? You got to be kidding me. I ask myself and I still can't get the answer. Let's say, I hide the image, so? Who the fck will look for it? I don't think that you have a picture of dead body on your computer and FBI search for it. Maybe 1 of million people can find this useful. RE: [Release/Source] ImageSteg - hide one image in another - Deque - 11-08-2012 (11-08-2012, 04:19 PM)FunKx Wrote:(11-08-2012, 01:09 PM)Deque Wrote:(11-08-2012, 12:54 PM)FunKx Wrote: Umm. One question. Why would you want to hide an image in image? Ridiculous.
And what you also fail to see is:
You really have first world problems complaining about something you get for free. RE: [Release/Source] ImageSteg - hide one image in another - FunKx - 11-08-2012 Yeah, still the usefulness percentage is really low. I didn't ask you to state my problems. Just check my sig. Specially dedicated for you. |