Skip to content

Instantly share code, notes, and snippets.

@companje
Created January 30, 2016 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save companje/a70fe3b13e6269b1238f to your computer and use it in GitHub Desktop.
Save companje/a70fe3b13e6269b1238f to your computer and use it in GitHub Desktop.
Analyse RGB file in Processing
byte bytes[];
int x = 0;
int y = 0;
int maxX = 431;
void setup() {
bytes = loadBytes("zaagsel-1000000bytes.rgb");
size(500, 1000);
}
void draw() {
background(0);
x=0;
y=0;
for (int i=0; i<bytes.length-3; ) {
char r = char(bytes[i++] & 255);
char g = char(bytes[i++] & 255);
char b = char(bytes[i++] & 255);
set(x, y, color(r, g, b));
if (++x>maxX) {
x=0;
y++;
}
}
}
void mouseMoved() {
maxX = mouseX;
}
void keyPressed() {
if (keyCode==LEFT) maxX--;
if (keyCode==RIGHT) maxX++;
if (key==' ') println(maxX);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment