ArrayIndexOutOfBoundsException:40199
in
Programming Questions
•
1 year ago
I saw the different answers to this kind of question but i didn't found any answer for my problem:
When I run this sketch it works but after a time it takes me this "error":
PImage img;
int x, y;
float r, g, b;
void setup(){
size(200,200);
img = loadImage("sunflower.jpg");
}
void draw(){
loadPixels();
img.loadPixels();
int loc = x + y*width;
r = red(img.pixels[loc]);
g = green(img.pixels[loc]);
b = blue(img.pixels[loc]);
pixels[loc] = color(r,g,b);
x++;
if (x>width){
y++;}
if (y>height){
y=0;
}
background(pixels[loc]);
}
Can anybody help me?
Thanks!
Agustín
When I run this sketch it works but after a time it takes me this "error":
PImage img;
int x, y;
float r, g, b;
void setup(){
size(200,200);
img = loadImage("sunflower.jpg");
}
void draw(){
loadPixels();
img.loadPixels();
int loc = x + y*width;
r = red(img.pixels[loc]);
g = green(img.pixels[loc]);
b = blue(img.pixels[loc]);
pixels[loc] = color(r,g,b);
x++;
if (x>width){
y++;}
if (y>height){
y=0;
}
background(pixels[loc]);
}
Can anybody help me?
Thanks!
Agustín
1