mxPngEncodeParam param = mxPngEncodeParam.getDefaultEncodeParam(image);
param.setCompressedText(new String[] { "mxGraphModel", xml });
// Saves as a PNG file
FileOutputStream outputStream = new FileOutputStream(new File(graphFileNameOut));
try {
mxPngImageEncoder encoder = new mxPngImageEncoder(outputStream, param);
if (image != null) {
encoder.encode(image);
}
else {
JOptionPane.showMessageDialog(graphComponent, mxResources.get("noImageData"));
}
}