We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › having a range of pics uploaded
Page Index Toggle Pages: 1
having a range of pics uploaded (Read 737 times)
having a range of pics uploaded
Mar 23rd, 2007, 4:40am
 
now im stuck with another problem.. where i wish to upload a range number of pictures from the data folder... do i need to type PImage for more than once...meaning for each pics i have to type this inorder for it to work.....is there anyway i could set a range...eg.." picture1,jpg to picture10.jpg" and all 10 pictures will load to the workspace ?...

really wish to know if this is possible and if so how it actually works..thanx....
Re: having a range of pics uploaded
Reply #1 - Mar 23rd, 2007, 7:40am
 
You can store your PImages in an array. So you can load them in a for-loop like this:
[code]
PImage[] pics;

void setup(){
pics=new PImage[10];
for(int i=0;i<pics.length;i++){
pics[i]=loadImage("picture"+i+".jpg");
}
}
Now all the pictures are in the pics array and you can access them like pics[1], pics[2] and so on.
Re: having a range of pics uploaded
Reply #2 - Mar 27th, 2007, 8:36am
 
hey thanks for the quick respond....

actually ive been trying it so many times but simply i just cant get it right.. as you were saying bout loop and array..im not really sure of it usage...could u please just show a clearer example. ( there is no script problem or anything. the stage loads but not the pics...hope to i can get some help really soon..thanks a million...

'Mal
Re: having a range of pics uploaded
Reply #3 - Mar 27th, 2007, 9:48am
 
Code:

PImage[] pics;

void setup() {
pics=new PImage[10]; // 10 images -> picture0.jpg to picture9.jpg
for(int i=0;i<pics.length;i++) {
pics[i]=loadImage("picture"+i+".jpg");
}
}

int counter = 0;

void draw () {
image(pics[counter], 0,0);

counter++; // plus one
counter %= 10; // wrap around after 9
}


now put 10 images named picture0.jpg -> picture9.jpg into your datafolder and you're good to go.

F
Re: having a range of pics uploaded
Reply #4 - Apr 3rd, 2007, 10:20am
 
hey hi..thanks for the quick response..it really did help me solve the problem..just need to alter and its good to go....thanks !!!

cheers,
vraig
Page Index Toggle Pages: 1