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 › Screenshot difficulties
Page Index Toggle Pages: 1
Screenshot difficulties (Read 496 times)
Screenshot difficulties
Sep 6th, 2007, 4:05pm
 
Hi all, dunno if this is the right place for this, but it didn't seem to fit anywhere else, so I just choose here (of course move it if need/want be).

http://193.1.127.21/~slong/processing/

K, if you follow the link, you'll find the exact problem I have.  A PApplet on a standard html page, communicating easily with JavaScript, all good.  The problem is that I have a function in the PApplet that creates a screenshot from it's current state.  If you press a button from within the PApplet, you'll see this screenshot being printed out on the Java Console.

The problem, however is when you call this function from the JavaScript.  It'll crash and burn, giving off a nullPointerException at the source (as far as I can see) loadPixels().  I'm really stumped by this and don't really know what to do about it, because the same method is being called, but just one call is being made from inside the PApplet, one from outside.

If anyone has any help on this, I'd really, really appreciate it.
Re: Screenshot difficulties
Reply #1 - Sep 6th, 2007, 7:14pm
 
that sounds like the javascript call is happening when the screen/image is not ready.

try this: from javascript, set a value inside the sketch that it should save on next time through draw(). inside draw(), check if that's true, and if so, initiate your save sequence (and clear the flag).

otherwise, the message from javascript is likely to be coming through at a bad time.
Page Index Toggle Pages: 1