Example usage for org.jfree.chart ChartUtils encodeAsPNG

List of usage examples for org.jfree.chart ChartUtils encodeAsPNG

Introduction

In this page you can find the example usage for org.jfree.chart ChartUtils encodeAsPNG.

Prototype

public static byte[] encodeAsPNG(BufferedImage image) throws IOException 

Source Link

Document

Encodes a BufferedImage to PNG format.

Usage

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();
        }
    }
}