Yes, and breaks semantics for clone() - just pointing out that you don’t really want what you say you want! ![]()
Yes, definitely broken in 3.5.3. In fact, looks like some other uses of the pixel array are broken too. Going to do a diff on the sources.
However, creating a copy of a PGraphics via the pixel array is a daft idea anyway, particularly if the graphics is on the GPU. Just do this, which works correctly across renderers, and will perform vastly better -
static final String RENDER = P3D, URL =
"https://" + "Forum.Processing.org/" + "processing-org.jpg";
PImage img;
PGraphics clonedPg;
void settings() {
img = loadImage(URL);
size(img.width, img.height, RENDER);
smooth(8);
noLoop();
}
void setup() {
// Buggy for all renderers but JAVA2D under PDE 3.5.3:
final PGraphics pg = createGraphics(width, height, RENDER);
pg.beginDraw();
pg.blendMode(REPLACE);
pg.image(img, 0, 0);
pg.endDraw();
clonedPg = clonePGraphics(pg);
}
void draw() {
image(clonedPg, 0, 0);
}
PGraphics clonePGraphics(final PGraphics pg) {
final int w = pg.width, h = pg.height;
final PGraphics cloned = createGraphics(w, h, RENDER);
cloned.beginDraw();
cloned.blendMode(REPLACE);
cloned.image(pg, 0, 0);
cloned.endDraw();
return cloned;
}