int height = Math.min(1200, p.height * 4);
PGraphicsJava2D canvas = (PGraphicsJava2D) p.createGraphics(width,
height, PConstants.JAVA2D);
canvas.beginDraw();
prettyHints(canvas);
canvas.background(255);
r.render(canvas, 0, 0, canvas.width, canvas.height,true);
canvas.endDraw();
canvas.loadPixels();
PImage img = canvas.get();
canvas.dispose();