List of usage examples for org.jfree.chart ChartUtils encodeAsPNG
public static byte[] encodeAsPNG(BufferedImage image) throws IOException
From source file:net.sf.mzmine.chartbasics.graphicsexport.ChartExportUtil.java
public static void writeChartToPNG(JFreeChart chart, ChartRenderingInfo info, int width, int height, File fileName, int resolution) throws IOException { if (resolution == 72) writeChartToPNG(chart, info, width, height, fileName); else {/*w w w . j a v a2s . c o m*/ OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName)); try { BufferedImage image = paintScaledChartToBufferedImage(chart, info, out, width, height, resolution, BufferedImage.TYPE_INT_ARGB); out.write(ChartUtils.encodeAsPNG(image)); } finally { out.close(); } } }