I'm just going throught the image tutorial on how to import an manipulate jpgs and whatnot. I changed the code a little, but I can't figure out why I'm getting this error... its always when the 3rd image (2.jpg) is loading. I tried duplicating the 2nd image, but it seems to be the code...
oh and I'm only displaying every 4 pixels to make the framerate faster.
Code:
PImage pimage;
int i = 0;
int timer = 1;
void setup(){
colorMode(HSB,100);
background(0,0,0);
frameRate(30);
size(640, 480);
pimage = loadImage("0.jpg");
}
void draw(){
println("timer is"+timer);
if(timer>=60){
pimage = loadImage(i+".jpg");
i++;
timer=1;
println("i is now "+i +".jpg");
int loc=0;
}
loadPixels();
// Since we are going to access the image's pixels too
pimage.loadPixels();
for (int y = 0; y < height; y+=4) {
for (int x = 0; x < width; x+=4) {
int loc = x + y*width;
// The functions red(), green(), and blue() pull out the 3 color components from a pixel.
float r = red(pimage.pixels[loc]);
float g = green(pimage.pixels[loc]);
float b = blue(pimage.pixels[loc]);
// Image Processing would go here
// If we were to change the RGB values, we would do it here, before setting the pixel in the display window.
//float adjustBrightness = ((float) mouseX / width) * 8.0;
float adjustBrightness = timer/2;
r *= adjustBrightness/4;
g *= adjustBrightness;
b *= adjustBrightness;
// Constrain RGB to between 0-255
r = constrain(r,0,255);
g = constrain(g,0,255);
b = constrain(b,0,255);
// Make a new color and set pixel in the window
color c = color(r,g,b);
pixels[loc] = c;
// Set the display pixel to the image pixel
pixels[loc] = color(r,g,b);
}
}
updatePixels();
timer++;
//}
}