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 › drawing into a PImage
Page Index Toggle Pages: 1
drawing into a PImage (Read 900 times)
drawing into a PImage
Oct 24th, 2005, 4:39am
 
Hi, I'm a returning user since the alpha days..  anyway, I remember there was a way to copy the "current" frame into an image object so i can keep a copy of the current frame and blend it into next draw cycle to do an echo effect..  only, I can't find a way to copy the current frame, and also can't find a way to make a "drawable" image object.

I rememeber, there was an undocumented object, called BImage or something like that, that allowed you to use all the draw methods like the shape methods.  I mean, PImage lets you directly set the pixels, so it's "draw-able", but not really in terms of the shape methods.  I remember I could go BImage.Image(blah, x, y) and draw into the BImage object, and then fiddle with it some more before finally displaying it onscreen with Image(BImage, x, y).  Was this a dream?
Re: drawing into a PImage
Reply #1 - Oct 24th, 2005, 10:58am
 
Did you mean PGraphics?

Code:

PGraphics3 gBuffer;
theSize=30;
gBuffer = new PGraphics3( theSize, theSize,null);
gBuffer.defaults();
gBuffer.background(0);
gBuffer.stroke(255);
gBuffer.beginShape(TRIANGLE_STRIP);
for(int i=0; i<6;i++){
gBuffer.vertex(random(0,theSize),random(0,theSize));
}
gBuffer.endShape();
image(gBuffer,0,0);


This will draw a random shape in new PGrahpic and put this image on the screen. There are some limitation with it. PGraphics3 dont support smooth() and I can't get this piece of code work with PGraphics or PGraphics2.
Re: drawing into a PImage
Reply #2 - Oct 24th, 2005, 11:05am
 
I dont know about that dream of yours, yet to get the contents to a screen you can call myImage = get(); as far as I remember a recent conversation.
Smiley
Re: drawing into a PImage
Reply #3 - Oct 27th, 2005, 2:09am
 
hmm... does PGraphics3 only support the shape methods?  Is there any way I can draw a bitmap into it?  Like

PGraphics3 buffer;
buffer.image(bitMap, x, y);
image(buffer, 0, 0);

Or if there's away to draw the output with image() first, and then copy that to Pgraphics3..  strange, I remembered doing this all the time in the alpha stage..  how do people do motion echo effects and feedback style effects without offscreen buffers?

Right now, I can forcefully capture the screen using:
Code:

PImage image;
loadPixels();
for (int i=0; i<width * height; i++)
{
 image.pixels[i] = pixels[i];
}
updatePixels();

but that was horrendously slow..
Re: drawing into a PImage
Reply #4 - Oct 27th, 2005, 9:17am
 
I've tried this and it's work:
Code:

PImage back=loadImage("xyz.jpg");
PImage pic=back.get(x,y,theSize,theSize);
gBuffer.image(pic,0,0);
image(gBuffer,0,0);
Re: drawing into a PImage
Reply #5 - Oct 27th, 2005, 5:22pm
 
hmm.. interesting.  I got the first frame to draw on the PGraphics3 object..  and for some reason, I'm not getting the subsequent frames.

by the way, where can I find documentation for PGraphics3?  Does one exist?
Re: drawing into a PImage
Reply #6 - Oct 30th, 2005, 1:40am
 
outside of the javadoc on dev.processing.org and what's described here, there is no documentation for PGraphics3, outside of the fact that it's what's used behind the scenes when you call size(300, 300, P3D). so any graphics command will work.

but as mentioned elsewhere on the board, it's not properly implemented. see also this bug: http://dev.processing.org/bugs/show_bug.cgi?id=92
Page Index Toggle Pages: 1