Bug 360 : copy() does not default to applet window with PImage
Last modified: 2007-02-03 12:28




Status:
RESOLVED
Resolution:
INVALID -
Priority:
P2
Severity:
normal

 

Reporter:
st33d
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2006-05-22 10:39
Can't get copy to default to the applet window when copying into a PImage.
I have to reference "g" in order to get it to work. No order of loading or
updating pixels seems to have an effect.

The commented line reproduces the desired effect which copy() should have
executed previously in the code.

PImage pimage;
void setup(){
size(200, 200);
background(0);
ellipse(width / 2, height / 2, width, height);
pimage = new PImage(width / 2, height / 2);
loadPixels();
pimage.copy(0, 0, width, height, 0, 0, pimage.width, pimage.height);
pimage.updatePixels();
updatePixels();
//pimage.copy(g, 0, 0, width, height, 0, 0, pimage.width, pimage.height);
image(pimage, 0, 0);
}
Additional Comment #1 From fry 2007-02-03 12:28
you're misunderstanding the copy() command. the code

pimage.copy(0, 0, width, height, 0, 0, pimage.width, pimage.height);

will copy (0,0) (width,height) of itself, to (0, 0) (pimage.width,
pimage.height) of itself. you're copying a 200x200 area of empty pixels.
you're calling the copy() method of pimage, how's it supposed to know about
the main PApplet?

if you want to copy the main drawing surface, you need to call copy() with
no "pimage." in front of it.

or if you want to copy part of the main drawing surface, without using g,
use 'get()'.

PImage c = get() or even get(0, 0, 100, 100).