We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi, like this i can load images named v, numbered 01,02... and with extension .jpg but how to load all images from data folder ignoring the file names and extensions, so i don't need to rename all of them before loading?
PImage[] p = new PImage[20];
for (int i = 0; i < p.length; i++) {
p[i] = loadImage("v"+nf(i, 2) + ".jpg"); // how to rewrite this?
}
Answers
Similar to what I did below:
http://forum.processing.org/two/discussion/6104/associate-text-and-picture
that's not what he wants, because it's exactly the same as what he has, only four times longer and less readable.
read up on java Files. the listFiles() method will give you a list of files. iterate over them and call loadImage for each. they will all have to be images but anything that loadImage() can handle should be ok.
http://docs.oracle.com/javase/7/docs/api/java/io/File.html#listFiles()
Oh, if that's the case, I've got a solution from this thread below:
http://forum.processing.org/two/discussion/2578/how-to-filter-and-order-a-set-of-files
More relevant parts:
"ignoring file names and extensions...?" Could it look like this:
?
this works fine when all pics is added to sketch
only typing in path to pictures folder doesn't