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 › capturing & rotating the processing display screen
Page Index Toggle Pages: 1
capturing & rotating the processing display screen (Read 644 times)
capturing & rotating the processing display screen
Mar 25th, 2010, 11:37am
 
I'd like to grab an image of the current processing screen, rotate it a few degrees, and then draw it back to the screen.  I tried saving the current pixels[] array with loadPixels(), changing the coordinate frame of reference with rotate(), and then drawing the pixels[] back to the frame with updatePixels().  This didnt' work; I think pixels[] keeps the standard coordinate frame always.  

If I could convert pixels[] into a PImage, I could use image() to paste the PImage into the new coordinate frame (I checked with a regular imported image).  Does anyone know how to do this, or have other suggestions for capturing & rotating the display window?

                    thank you very much --

                                                 

                                               -- Todd
Re: capturing & rotating the processing display screen
Reply #1 - Mar 25th, 2010, 11:48am
 
You could iterate through the pixel array like this... http://processing.org/reference/PImage_loadPixels_.html
Re: capturing & rotating the processing display screen
Reply #2 - Mar 25th, 2010, 12:00pm
 
Create another PImage or PGraphics, copy the pixels of the sketch to this image, do your rotation and draw the offscreen image back to screen (with image()).
Re: capturing & rotating the processing display screen
Reply #3 - Mar 28th, 2010, 6:02pm
 
Yes thank you guys: the secret is to create a PImage, save the screen pixels into it, then draw that image in the next time step.

Code:
PImage img;

void setup(){
 img = createImage(width, height, RGB);
}

void draw(){
 // draw old screen...
 image(img, 0, 0);

 // change the screen...
[screen modifiying code here]

 // save current screen pixels...
 loadPixels();
 img.pixels = pixels;
 img.updatePixels();
}
Page Index Toggle Pages: 1