This should do it for PNG format:
BufferedImage image = mxCellRenderer.createBufferedImage(graph, null, 1, Color.WHITE, true, null);
ImageIO.write(image, "PNG", new File("C:\\Temp\\graph.png"));
Where
graph
is your mxGraph object. (NotemxCellRenderer
is a reference to a class not a variable, somxCellRenderer.createBufferedImage
is a static method call)."PNG"
is the format, and can be JPEG, PNG, GIF, BMP and WBMP out of the box. See here for more details.