Created
January 30, 2016 12:22
-
-
Save companje/a70fe3b13e6269b1238f to your computer and use it in GitHub Desktop.
Analyse RGB file in Processing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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