NullPointerException when calling save() after surface.setSize() in P2D

Are you resizing the window to make it big enough for the selections, or small enough to crop them? … In either case, you don’t need to do this. You can create a PGraphics of whatever size you want, draw onto that, and save it – no screen resizing needed.

Or create a PImage and copy part of the canvas onto that – assuming your canvas was big enough and you have already drawn onto the canvas – then save the PImage. You can do that with:

PImage myCrop = get(x, y, w, h);
myCrop.save("myCrop.jpg");
1 Like