Skip to content

Instantly share code, notes, and snippets.

@gifguide2code
Created July 9, 2018 01:22
Embed
What would you like to do?
A Processing sketch to pull messages out of pngs encoded with the ImageEncoder at https://gist.github.com/gifguide2code/382e99ee16e9defdaa9185979c3242ae
IntList numbers;
void setup () {
numbers = new IntList();
size(400, 317);
PImage Original = loadImage("Starry Night.jpg");
PImage Encoded = loadImage("Encoded.png");
Original.loadPixels();
Encoded.loadPixels();
for (int x=0; x<width;x++) {
for (int y=0;y<height;y++) {
int loc = x + y * width;
float rOrig = red(Original.pixels[loc]);
float gOrig = green(Original.pixels[loc]);
float bOrig = blue(Original.pixels[loc]);
float rEnc = red(Encoded.pixels[loc]);
float gEnc = green(Encoded.pixels[loc]);
float bEnc = blue(Encoded.pixels[loc]);
if ( (rOrig != rEnc) ){
numbers.append(int(rEnc - rOrig));
} else if (gOrig != gEnc) {
numbers.append(int(gEnc - gOrig));
} else if (bOrig != bEnc) {
numbers.append(int(bEnc - bOrig));
}
}
}
String abc = ". abcdefghijklmnopqrstuvwxyz";
for (int i=0; i<numbers.size();i++) {
int num = numbers.get(i);
print(abc.charAt(num));
}
}
void draw(){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment