Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This sketch hides messages in images of static.
void setup() {
size(600,600);
int step = 2;
int imgx = 0;
int imgy = 0;
int rand = 0;
PImage Poltergeist = loadImage("Poltergeist.png");
PImage Img = createImage(width,height,ARGB);
Poltergeist.loadPixels();
for (int x = 0; x<width;x++) {
for (int y = 0; y <height/step; y++) {
int loc = x + y*width;
rand = int(random(0,255));
int imgloc = imgx + imgy * width;
Img.pixels[imgloc] = color(rand);
imgy = imgy + step;
}
imgy = 0;
imgx = imgx + 1;
}
print(str(imgx));
for (int x = 0; x <width; x++) {
for (int y = 0; y < height/step; y++) {
int loc = x+y*width;
float r = red(Poltergeist.pixels[loc]);
float g = green(Poltergeist.pixels[loc]);
float b = blue(Poltergeist.pixels[loc]);
if ((r==255) && (g==255) && (b==255)) {
//Randomize the r, g, b values
rand = int(random(0,255));
r = rand;
g = rand;
b = rand;
}
int imgloc = imgx + imgy * width;
Img.pixels[imgloc] = color(r,g,b);
imgy = imgy + step;
}
imgy = 0;
imgx = imgx + 1;
}
Img.updatePixels();
image(Img, 0,0);
save("Message.png");
}
void draw() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.