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
screenGrab (Read 886 times)
screenGrab
Dec 10th, 2005, 10:52pm
 
Hi

I'd like to take a snapshot of the current output in a PImage instance . Is this possible ?
Re: screenGrab
Reply #1 - Dec 11th, 2005, 12:24am
 
Ah, now I've asked this question before. One of the properties in processing they don't tell you about is "g", the image of the applet.
Code:

void setup(){
rect(0,0,10,10);
loadPixels();
PImage screenGrab = g.get();
for(int i = 0; i < 10; i++)
image(screenGrab, i*2, i*2);
}
Re: screenGrab
Reply #2 - Dec 11th, 2005, 1:12am
 
thank you,

this works !
but there's a but...
once I issue the g.get() , my app forgets my Camera ...

If I comment g.get() out , the app works Sad

any idea ?
Re: screenGrab
Reply #3 - Dec 11th, 2005, 1:49am
 
any idea where I can find the definition (class) of the var g ?
Re: screenGrab
Reply #4 - Dec 11th, 2005, 2:58am
 
PImage screen = get();
will do the same thing. no need to use g.get(). most calls to g.whatever are already handled so that you shouldn't have to use g dot anything.
Re: screenGrab
Reply #5 - Dec 11th, 2005, 3:21pm
 
I have a bug in my app using CaptureEvent. It only appears if I issue loadPixels() in the draw() function. Is there anything that could make loadPixels interfere with a camera ? It might help me if I can read the source of loadPixels(). Is it available somewhere ?

thanks
Re: screenGrab
Reply #6 - Dec 11th, 2005, 11:32pm
 
Would you mind reducing your code to what reproduces the bug and posting it so we can all have a crack at it?
Re: screenGrab
Reply #7 - Dec 12th, 2005, 10:26am
 
Here's the source for PGraphics2 where loadPixels is:
http://dev.processing.org/source/index.cgi/trunk/processing/core/PGraphics2.java?view=markup

Code:

public void loadPixels() {
if ((pixels == null) || (pixels.length != width * height)) {
pixels = new int[width * height];
}
((BufferedImage) image).getRGB(0, 0, width, height, pixels, 0, width);
}


Doesn't seem to do much harm..

-seltar
Page Index Toggle Pages: 1