We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I will like to create a function that will loads images in an array. I have 10 different folders with different numbers of images, let’s call them folder1 to folder 10. all images will be naming the same 1.png to...... different for each one (let say for now 700)
I will like to load all the data this is where I have my problem now. - will need to be able to access image with Image - have a variable of the total amount of the image in a folder
In draw: I will choose randomly 1 folder and from that folder chose a random image between a range. Each draw will upgrade that range. 1st range: round( 0% to 1.4%) 2st range: round( 1.4% to 2.8%)
I know my code is not working I am missing some information counting all image and the array of images for each folder. hope i am near the solution.
import processing.pdf.*;
PImage frame[]; //image from the folder
int totalPage=96; //number of page
float page=1;
float pageNow= 100*page/totalPage; //the last limit
float pageAdd= 100*1/totalPage; // time gape in a page
float pageBefor= pageNow-pageAdd; //the first limit
String [] MovieID; //name of the folder
int [] tFMovieID; //total image in folder
void setup() {
size(840, 640);
smooth();
frameRate(1);
MovieID = new String[10];
MovieID[0] = "tt0063442"; // Planet of the Apes
MovieID[1] = "tt0074812"; // Logan's Run
MovieID[2] = "tt0089092"; // Enemy Mine
MovieID[3] = "tt0114746"; // Twelve Monkeys
MovieID[4] = "tt0119177"; // Gattaca
MovieID[5] = "tt0120907"; // eXistenZ
MovieID[6] = "tt0212720"; // A.I. Artificial Intelligence
MovieID[7] = "tt1798709"; // Her
MovieID[8] = "tt0816692"; // Interstellar
MovieID[9] = "tt0470752"; // ex-machina
//Chappie tt1823672
tFMovieID= new int[10];
tFMovieID[0] = MovieID[0] counting all image; // here i don't know
//....
tFMovieID[9] = MovieID[9] counting all image; // here i don't know
}
void draw() {
beginRecord(PDF, "###.pdf");
background(255);
int numberM= random(0,11);
totalframe= tFMovieID[numberM];
selecImage = random ( totalframe*(pageBefor/100), totalframe*(pageNow/100));
frame = loadImage(MovieID[numberM]+"/"+selecImage+".png");
image(frame, 100, 100);
pageInfo();
/*grid();
pushMatrix();
translate(400, 0 );
grid();
popMatrix();*/
cutLine();
endRecord();
page=page+1;
if (frameCount >totalPage) {
exit();
}
}
Answers
I am now trying to make a double array[][] to load my image the firs is the folder and the other is the image number.
I imagine this is not the good technique because I have a null point exception.