是否可以将图像/BufferedImage转换为JFreeChart?
发布于 2011-08-10 12:51:50
将图像转换为JFree是不可能的。要从JFreechart创建映像,您可以执行以下操作:
BufferedImage objBufferedImage=objJFreechart.createBufferedImage(600,800);
ByteArrayOutputStream bas = new ByteArrayOutputStream();
try {
ImageIO.write(objBufferedImage, "png", bas);
} catch (IOException e) {
e.printStackTrace();
}
byte[] byteArray=bas.toByteArray();这将创建byte[]。
现在,您需要从byte[]创建映像。下面的代码就是这样做的。
InputStream in = new ByteArrayInputStream(obj);
BufferedImage image = ImageIO.read(in);
File outputfile = new File("image.png");
ImageIO.write(image, "png", outputfile);镜像将在创建项目的位置(本地驱动器)创建。
发布于 2012-12-07 16:06:40
JfreeChart首先获取数据,并使用通用的ChartUtilities类或任何自定义的实用程序类生成图像。
ChartUtilities.writeChartAsPNG(outputstream,getDataset(), width,height);也许这能帮到你:here
发布于 2011-03-12 01:16:04
JFreeChart对象用于制作图像,它不使用图像,并且图像不能转换为JFreeChart对象。请参阅:http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html
https://stackoverflow.com/questions/5272966
复制相似问题