We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am trying to optimize a sketch where instead of loading 200 images to an array, I am loading only 10 at a time that are cycled through, but keeps updating throughout the sketch so it goes through all the images. I have read elsewhere in the forum that a good way to do this is to use an ArrayList, but I am not sure how to create an ArrayList of images that calls up images from a folder.
I got as far as this:
String basedir = "/Users/admin/Desktop/Borderscape_OF/test";
String fileext = ".jpg";
ArrayList<PImage> imgList = new ArrayList<PImage>();
java.io.File folder = new java.io.File(dataPath(basedir));
java.io.FilenameFilter extfilter = new java.io.FilenameFilter() {
boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(fileext);
}
};
void setup() {
fullScreen();
frameRate(7);
background(0);
filenames = folder.list(extfilter);
imgList = new ArrayList<PImage>();
for (int h = 0; h < 10; h++) {
imgList.add(new PImage());
}
}
But now I am stuck.
Answers
It is really good to share previous resources as it gives insight of what you know and what have been tried before (less code to write for me).
A quick inspection revels you have already a post going: https://forum.processing.org/two/discussion/comment/121189/#Comment_121189 Why to open a new post? Why not to continue there? Opening multiple posts creates duplicate and disperse answers... not good for the forum.
Kf
I thought since it was addressing a different question/concern, it would be okay to open a new post. I can delete this thread and carry on in the other, but I can't find a way to do that. I will make sure not to do so in the future.
This is what I came across:
https://forum.processing.org/two/discussion/767/dynamic-image-array