Code for listing/loading images
Not example code that I would recommend using and not a final version.
This code gets image names from different folders and then loads the images from the data folder. Next thing to do is resizing all images when loading them to have them ready to be displayed.
String[] photoNamesRow1; String[] photoNamesRow2; String[] photoNamesRow3; String[] photoNamesRow4;
PImage[] photoRow1; PImage[] photoRow2; PImage[] photoRow3; PImage[] photoRow4;
File dir1; File dir2; File dir3; File dir4;
void setup() { //fullScreen(); size(700,500); background(0); noStroke();
dir1 = new File(dataPath("C:/Users/yourpathhere/data/Row1")); dir2 = new File(dataPath("C:/Users/yourpathhere/data/Row2")); dir3 = new File(dataPath("C:/Users/yourpathhere/data/Row3")); dir4 = new File(dataPath("C:/Users/yourpathhere/data/Row4"));
photoNamesRow1 = dir1.list(); if (photoNamesRow1 == null) { println("-- file row 1 not found"); return; } else {
for (int i=0; i<photoNamesRow1.length; i++) { println (photoNamesRow1[i]); } } println(photoNamesRow1.length+" files found in Row1");
photoNamesRow2 = dir2.list(); if (photoNamesRow2 == null) { println("-- file row 2 not found"); return; } else {
for (int i=0; i<photoNamesRow2.length; i++) { println (photoNamesRow2[i]); } } println(photoNamesRow2.length+" files found in Row2");
photoNamesRow3 = dir3.list(); if (photoNamesRow3 == null) { println("-- file row 3 not found"); return; } else {
for (int i=0; i<photoNamesRow3.length; i++) { println (photoNamesRow3[i]); } } println(photoNamesRow3.length+" files found in Row3");
photoNamesRow4 = dir4.list(); if (photoNamesRow4 == null) { println("-- file row 4 not found"); return; } else {
for (int i=0; i<photoNamesRow4.length; i++) { println (photoNamesRow4[i]); } } println(photoNamesRow4.length+" files found in Row4");
photoRow1 = new PImage[photoNamesRow1.length]; for ( int i = 0; i< photoNamesRow1.length; i++ ) { String photoNameRow1 = photoNamesRow1[i]; photoRow1[i] = loadImage(photoNameRow1); }
photoRow2 = new PImage[photoNamesRow2.length]; for ( int i = 0; i< photoNamesRow2.length; i++ ) { String photoNameRow2 = photoNamesRow2[i]; photoRow2[i] = loadImage(photoNameRow2); }
photoRow3 = new PImage[photoNamesRow3.length]; for ( int i = 0; i< photoNamesRow3.length; i++ ) { String photoNameRow3 = photoNamesRow3[i]; photoRow3[i] = loadImage(photoNameRow3); }
photoRow4 = new PImage[photoNamesRow4.length]; for ( int i = 0; i< photoNamesRow4.length; i++ ) { String photoNameRow4 = photoNamesRow4[i]; photoRow4[i] = loadImage(photoNameRow4); }
}
void draw() {
PImage startImage = photoRow1[0]; startImage.resize(0, height/2); //PImage startImage = photoRow1[int(random(photoRow1.length))]; image(startImage, 0, 0);
}
















