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.
Page Index Toggle Pages: 1
saveFrame help! (Read 416 times)
saveFrame help!
Apr 23rd, 2008, 12:33am
 
I want to use copy to output successive iterations of an image file.

Meaning, I want to get many discreet images out of 1 image, using the copy tool.

I've been experimenting with saveFrame but I haven't had any success.

For instance, the code below, I would expect to get 10 images, but I get 1 image.
thanks in advance for any help!



int y=0;
PImage img = loadImage("big_j_ceasar.jpg");
image(img, 0, 0,800,600);
size(1000,800);
for( int j=0;j<10;j++){
 print (j);
   for ( int k = 0; k<8;k++){
     for ( int i = 0; i<20;i++){
           copy(int(random(1,800)), int(random(1,800)), 50, 50, i*50, y, 50, 50);
           noFill();
           }

     y=y+100;

     };

saveFrame("output-####.jpg");
 }
Re: saveFrame help!
Reply #1 - Apr 23rd, 2008, 12:44am
 
I think that saveFrame("thing-####.jpg"); will only work in the setup()/draw() style of program.

The #### is replaced by the frame number, but in your code there's only one frame as far as processing's concerned. So you'll have to change it to saveFrame("output-"+i+".jpg");
Re: saveFrame help!
Reply #2 - Apr 23rd, 2008, 12:57am
 
excellent, thanks for the syntax help!

speaking of syntax, and only mildly related:

while I've got you here can you help me create an array of images, or pointers to images, such that

[image1, image2, image3,image4]
etc.

or, what kind of datatype would I specify in that instance?

and, if you happen toknow whether someone has already written code to load all images in a folder into an array that would be extra-special nice.
(I'm new to processing, cna you tell?)

something like

array= [0..10]
while < arraySize)  {

      array[i] = loadImage(("data/*.jpg").
}


thanks..!


Re: saveFrame help!
Reply #3 - Apr 23rd, 2008, 1:34am
 
There are two ways of getting that to work. the first one would be to create an array of PImage Objects.
I guess thats the way if you want to display all images at the same time. If you'd only want to display one of those images at a time just save the image names in an array and attach them to you PImage object. something like:

PImage myImage;
String[] images =  new String[2];

void setup(){
size(400, 400);
images[0] = "image1.jpg";
images[1] = "image2.jpg";
myImage = loadImage(images[round(random(1))]);
}
void draw(){
image(myImage, 0, 0);
}
Re: saveFrame help!
Reply #4 - Apr 23rd, 2008, 1:45am
 
thanks for the quick reply.
that helps a bit.

do youn know what type ofdata is a PImage?
(for setting up an array

Also, what I'm really looking for, is for the right method to
call that will save lazy me from typing in all those image names.
I imagine there must be some easy way to do that in Processing?
Re: saveFrame help!
Reply #5 - Apr 23rd, 2008, 9:10am
 
Maybe you should simply take a look at array syntax in processing in general. if you want to have an array of PImage Objects simply write:

PImage[] images = new PImage[10];

you can than simply load them through a for loop. anyways as I said before it depends on what you want to use your images for and especially if you want to display all at one or just switch between them.

for(int i=0; i<images.length; i++){
images[i] = loadImage("image"+i+".jpg");
}
Page Index Toggle Pages: 1