Processing Array size

I have a Processing sketch that reads folders of images and displays them.

It has been working great but it seems that as soon as the folder got over 500 images I get an error.

My code is pretty straight forward.

I define a Pimage array at the start of my sketch

PImage gridImage[];

Then populate the array with the images from the folder.

gridImage[i] = loadImage(f.getName() );

It works great until I seem to max out the array as I get and “array out of bounds error” if there are more than 500 images in the folder.

Any ideas?

1 Like

You need to set you array length to the number of images in the folder …

if you don’t know that number then you can use an ArrayList.

1 Like

Cool, I’ll try that.

Seems odd that it would work for 499 images then fail.


yeah … i’m not sure how you get 499 without allocating memory.

1 Like

Ok… sorted… I had defined the array length further down the sketch when I first started… thinking there was no way I would have more than 500 images…

Thanks for all the suggestions