我保存的JFreeChart为JPEG文件的方法是:保存为.jpg文件的图像:Java的
JFreeChart chart = ChartFactory.createXYLineChart(
"Hysteresis Plot", // chart title
"Pounds(lb)", // domain axis label
"Movement(inch)", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
true, // tooltips
false // urls
);
然后:
image=chart.createBufferedImage(300, 200);
的图像appeas为:
我的保存功能是:
public static void saveToFile(BufferedImage img)
throws FileNotFoundException, IOException
{
FileOutputStream fos = new FileOutputStream("D:/Sample.jpg");
JPEGImageEncoder encoder2 =
JPEGCodec.createJPEGEncoder(fos);
JPEGEncodeParam param2 =
encoder2.getDefaultJPEGEncodeParam(img);
param2.setQuality((float) 200, true);
encoder2.encode(img,param2);
fos.close();
}
我叫它为:
try{
saveToFile(image);
}catch(Exception e){
e.printStackTrace();
}
保存的图像appeas为:
任何建议,在那里我错了或如何保存它的显示方式,也可以我需要保存为.png。任何人都可以让我知道如何保存为.png?
感谢
关于另存为png的信息,http://docs.oracle.com/javase/tutorial/2d/images/saveimage.html – Coffee 2013-02-26 17:58:30