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 › Get/Save/CreateGraphics
Page Index Toggle Pages: 1
Get/Save/CreateGraphics (Read 862 times)
Get/Save/CreateGraphics
Oct 20th, 2009, 3:25pm
 
Hi,

I was wondering how I create an PImage of my full image and not only of the image visible. My image is bigger than the display and if I call get() for instance I only get what I see. Same with save and createGraphics.

Using width, height returns the same result.

Thanks,
Lynas
Re: Get/Save/CreateGraphics
Reply #1 - Oct 20th, 2009, 11:44pm
 
yep, if you have a PGraphics object named "myOffscreenImage" you can just call myOffscreenImage.get()...same with .saveFrame(), etc.
Re: Get/Save/CreateGraphics
Reply #2 - Oct 21st, 2009, 1:23am
 
So next to the onscreen image I have to create an offscreen image as well?
Re: Get/Save/CreateGraphics
Reply #3 - Oct 21st, 2009, 2:52am
 
Well, yes, it makes sense since your image won't fit in the window...
In case you are wondering, no, you cannot create an onscreen image bigger than the window. That's not really a problem, onscreen image rarely takes much memory.
Re: Get/Save/CreateGraphics
Reply #4 - Oct 21st, 2009, 4:28am
 
You can also save yourself the hassle of creating and always drawing onto the offscreen image by using the size(width,height) command to make the onscreen image large enough.  Or am I missing something here?

Code:
size(10000, 100);
line(0, 0, 10000, 100);
save("test.png");

Re: Get/Save/CreateGraphics
Reply #5 - Oct 21st, 2009, 6:08am
 
But then the image is very large, right?
Re: Get/Save/CreateGraphics
Reply #6 - Oct 21st, 2009, 3:05pm
 
Yes, but it will also be very large if you create an off-screen buffer.

What exactly did you mean by "my full image" and "visible image" in your original post?

You could make things fit into a smaller area by using a transformation matrix:
Code:
size(100, 100);
pushMatrix();
scale(0.5);
line(0, 200, 200, 0);
popMatrix();
save("test.png");

This will produce a 100x100 pixel PNG with a diagonal line, even though the line coordinates were beyond the image boundaries (but scaled down to fit).
Page Index Toggle Pages: 1