FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   screengrab
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: screengrab  (Read 803 times)
pinksalmon


screengrab
« on: Feb 25th, 2003, 4:08pm »

I want to work with sreenGrab(); but I think I need to know some ins and outs.
First of all; in which folder should those tiff files be dropped? Since I can't find anything with this example code below, can anybody tell me what I do wrong and give me some tips regarding this subject?:
 
boolean scrnShot = false;
void setup(){
  size(100,100);
  //noBackground();
  background(#FF0000);
}
 
void loop(){
  curve(random(200),random(200),random(200),random(200),random(200),random (200),random(200),random(200));
  if(scrnShot==true) screenGrab();
}
 
void keyPressed(){
  if(key==' '){
    scrnShot = true;
  }
}
void keyReleased() {
  scrnShot = false;
}
 
REAS


WWW
Re: screengrab
« Reply #1 on: Feb 25th, 2003, 4:58pm »

This code works. Look for the images in the same directory as your Proce55ing.exe. It will only work when running from the Processing environment. Just make sure you key the key pressed the entire time you want to save images.
 
fry


WWW
Re: screengrab
« Reply #2 on: Feb 25th, 2003, 9:17pm »

hm, would it make more sense to put the screengrabs into the sketch folder? that could be added.
 
also, a simpler version of your code would go:
 
Code:
void loop() {
  curve(random.. etc
   
  if (keyPressed && (key == ' ')) screenGrab();
}

no need for the extra keyPressed() / keyReleased() fellas and the scrnShot boolean, at least until you want to do something more fancy..
 
benelek

35160983516098 WWW Email
Re: screengrab
« Reply #3 on: Feb 26th, 2003, 9:32am »

'cept that Fry's code will create a screengrab every time the loop() repeats, as long as the <spacebar> is down. so if u have a tendency of holding the button down for longer than an instant, u'll have 30 or so screengrabs hehe, i should probably go delete those tiff's now...
 
benelek

35160983516098 WWW Email
Re: screengrab
« Reply #4 on: Feb 26th, 2003, 2:23pm »

hey u know, i wouldn't mind having an easy (easier?) way to just get regular printscreens for project documentation, and such. they could be labelled according to date and time and put in the sketch folder, as u suggested.
 
would that be possible, within the java framework?
 
-jacob
 
fry


WWW
Re: screengrab
« Reply #5 on: Feb 26th, 2003, 2:24pm »

the original should do that as well. i'm quite certain the two pieces of code are identical in function.  
 
in the first version of the app, scrnShot stays 'true' until the mouse is released (just like mousePressed), meaning that it will spew screen grabs to your folder each time it goes through loop the same way as the version i had posted.
 
if you only want it to grab once, you might use the original version, and set scrnShot to false after doing the screenGrab(). (keyReleased could be removed at that point).
 
fry


WWW
Re: screengrab
« Reply #6 on: Feb 26th, 2003, 2:31pm »

on Feb 26th, 2003, 2:23pm, benelek wrote:
hey u know, i wouldn't mind having an easy (easier) way to just get regular printscreens for project documentation, and such. they could be labelled according to date and time and put in the sketch folder, as u suggested.

 
this is a chunk of the code for screenGrab(). it uses an internal function called makeTiffData, which will change its name in the future, so don't be sad if code based on that later breaks.
 
nf() is a number-formatting function which is in my copy of 52 that i'm working on but haven't released.  
 
Code:
   try {
 FileOutputStream fos =  
 new FileOutputStream("screen-" +  
        nf(screenGrabCount++, 4) + ".tif");
 fos.write(makeTiffData(pixels, width, height));
 fos.flush();
 fos.close();
    } catch (IOException e) {
 e.printStackTrace();
    }

then it gets really hacky, to do it from your own code (rather than from inside p5).. the variable PdeBase.editor.sketchDir should be a java File object that is the base of the sketch directory. (you'll have to try it out to see if it works, i may be missing something). you'll have to fiddle a bit and see how it goes.
 
pinksalmon


Re: screengrab
« Reply #7 on: Feb 28th, 2003, 2:07pm »

So screenGrabs are only possible when executed within processing itself? Are there any ways or plans going that way that you create screenGrabs from an applet. Or is that going to last a while?
 
By the way; My proce55ing directory was stuffed with TIFFs indeed!! (My machine works properly again...)
 
fry


WWW
Re: screengrab
« Reply #8 on: Mar 3rd, 2003, 8:08pm »

no plans to make them work from applets, since applets aren't allowed to write to your disk.. it's a security restriction built into all java applets.
 
getting around this requires all sorts of mess with certificates and signed applets.. simplifying that process would be waaay down the todo list.
 
benelek

35160983516098 WWW Email
Re: screengrab
« Reply #9 on: Mar 4th, 2003, 4:39am »

isn't Processing itself a java application?
 
fry


WWW
Re: screengrab
« Reply #10 on: Mar 4th, 2003, 5:25am »

yeah, p5 is an application, not an applet. it runs local on your machine and has no security restrictions, but an applet runs from a web page and has limited access to resources, like it can't access your local disk or connect to servers besides the one from which it came.
 
benelek

35160983516098 WWW Email
Re: screengrab
« Reply #11 on: Mar 5th, 2003, 7:46am »

ooh, cool. just tested it - if u use screenGrab from within an applet that's being run as an application, it'll place the TIFF's in the applet directory.
 
-jacob
 
REAS


WWW
Re: screengrab
« Reply #12 on: Feb 11th, 2004, 4:39am »

screenGrab() is depricated.
we not offer the improved save() and saveFrame()
please see the reference for details.
 
+ casey
 
Pages: 1 

« Previous topic | Next topic »