We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Question: should I report this as a bug? Or is this considered user error?
Evidently, calling image() on a PGraphics object that hasn't been drawn into generates a NullPointerException. The following program generates a NullPointerException:
void setup() {
size(800,800);
PGraphics pg = createGraphics(800, 800);
pg.colorMode(HSB, 1.0);
image(pg, 0, 0); // NullPointerException here
}
The following program works without error:
void setup() {
size(800,800);
PGraphics pg = createGraphics(800, 800);
pg.colorMode(HSB, 1.0);
pg.beginDraw();
pg.endDraw();
image(pg, 0, 0); // now it works without error
}
Answers
As I've already pointed out in your previous thread:
http://forum.processing.org/two/discussion/4637/newbish-ferreting-out-the-cause-of-a-nullpointerexception
Calling beginDraw() once had always been a requirement for PGraphics as far as I know Processing since v1.5.1!
http://processing.org/reference/PGraphics.html
http://processing.org/reference/PGraphics_beginDraw_.html