IF3Si/pde/IF3Si/getImages.pde

53 lines
1.8 KiB
Plaintext
Raw Permalink Normal View History

2015-09-11 15:19:44 +02:00
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
This file is part of "Interface Fractures III - Silicon".
Copyright (c) 2015 Luka Prinčič, All rights reserved.
This program is free software distributed under
GNU General Public Licence. See COPYING for more info.
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
getImages.pde
*/
// loads all images into an array - - - - - - - - - - - - - - - - - - - - - - - - -
PImage[][] getImages(String folder) {
2015-09-24 09:28:56 +02:00
//ArrayList<ArrayList> getImages(String folder) {
2015-09-11 15:19:44 +02:00
PImage[][] imgPool; // declare 2D array imgPool
2015-09-24 09:28:56 +02:00
//ArrayList<ArrayList> imgPool;
2015-09-11 15:19:44 +02:00
File dir = new File(dataPath(sketchPath + folder)); // first folder
String[] dirlist = dir.list(); // an array of folders (strings)
dirlist = sort(dirlist); //
2015-09-24 09:28:56 +02:00
//imgPool = new ArrayList<ArrayList>();
imgPool = new PImage[dirlist.length][100]; // create 2d array imgPool
2015-09-11 15:19:44 +02:00
for (int i = 0; i < dirlist.length; i++) {
String fulldir = dataPath(sketchPath + folder + dirlist[i]) + "/";
File dir2 = new File(fulldir);
String[] filelist = dir2.list(); // an array of image names
filelist = sort(filelist);
2015-09-24 09:28:56 +02:00
println("\n~~~ BANK no." + i + ": " + dirlist[i]);
2015-09-11 15:19:44 +02:00
if (filelist.length != 0) {
2015-09-24 09:28:56 +02:00
imgPool[i] = (PImage[]) expand(imgPool[i], filelist.length);
// geez: ^^^^^^^^^^ !!!!!
2015-09-11 15:19:44 +02:00
for (int j = 0; j < filelist.length; j++) {
2015-09-24 09:28:56 +02:00
println(" imgPool[" + i + "][" + j + "]: " + dirlist[i] + " " + filelist[j]);
2015-09-11 15:19:44 +02:00
imgPool[i][j] = loadImage(fulldir + filelist[j]);
}
} else {
println("No files in this folder: " + fulldir);
}
}
2015-09-24 09:28:56 +02:00
println("\n~~~ Done loading images.\n");
2015-09-11 15:19:44 +02:00
return imgPool;
}