problem with images and pixels tutorial
in
Programming Questions
•
1 year ago
i took some code out of the tutorial and modificated it a little bit, i keep getting the error "ArrayIndexOutOfBoundsException: 25600" don't know what it means so i can't fix it could anyone help me?
here is the program:
PImage img;
void setup() {
size(200, 200);
img = loadImage("fox1.jpg"); //this image's size is 200x200 so it should fit perfectly
}
void draw() {
loadPixels();
// Since we are going to access the image's pixels too
img.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;
// The functions red(), green(), and blue() pull out the 3 color components from a pixel.
float r = red(img.pixels[loc]);
float g = green(img.pixels[loc]);
float b = blue(img.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.
// Set the display pixel to the image pixel
pixels[loc] = color(r,g,b);
}
}
updatePixels();
}
here is the program:
PImage img;
void setup() {
size(200, 200);
img = loadImage("fox1.jpg"); //this image's size is 200x200 so it should fit perfectly
}
void draw() {
loadPixels();
// Since we are going to access the image's pixels too
img.loadPixels();
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int loc = x + y*width;
// The functions red(), green(), and blue() pull out the 3 color components from a pixel.
float r = red(img.pixels[loc]);
float g = green(img.pixels[loc]);
float b = blue(img.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.
// Set the display pixel to the image pixel
pixels[loc] = color(r,g,b);
}
}
updatePixels();
}
1