loading a dynamic array of images
in
Programming Questions
•
3 years ago
hi
i'm making a gallery and need some help with loading the images for the gallery.
I understand how to use PImage in a non-dynamic situation (i.e where the number of images that need to be loaded stays the same). however what i am trying to do is to load an external text file (which is working through loadStrings). the problem is that the amount of lines that make up the text file can change, making the .length of the array that the data is stored in dynamic. in my understanding, in order to load an image once PImage has been declared and loadImage() has the name of the PImage data type assigned to it image() can then be used to actually draw the image to the screen.
the problem i have here with my gallery is that i cannot declare the PImage data holder as an array, is this necessary? or is there another way of doing this?
for example
i'm making a gallery and need some help with loading the images for the gallery.
I understand how to use PImage in a non-dynamic situation (i.e where the number of images that need to be loaded stays the same). however what i am trying to do is to load an external text file (which is working through loadStrings). the problem is that the amount of lines that make up the text file can change, making the .length of the array that the data is stored in dynamic. in my understanding, in order to load an image once PImage has been declared and loadImage() has the name of the PImage data type assigned to it image() can then be used to actually draw the image to the screen.
the problem i have here with my gallery is that i cannot declare the PImage data holder as an array, is this necessary? or is there another way of doing this?
for example
- String[] img = loadStrings("stuff.txt");
PImage name[]; //this does not seem to work?
for(i = 0; i <= img.length; i++){
println(name[i]);
}
- for(i=0; i <= img.length; i++){
//each line of the external text file has the actual name of the image being loaded eg pic.jpg - name[i] = loadImage(img[i])
- }
1