http://blog.chinaunix.net/uid-7671779-id-2599207.html
ChartDirector是一个很好用的生成图表的库,用c++开发,提供了c++接口.
![]() |
|
现在以安装包中带的softlightbar文件夹中的工程为例,把图表输出到网页
1,先把工程的输出文件设为.cgi扩展名
2,工程中默认是生成图片文件,就是这句: c->makeChart("posnegbar.png");
现在我们需要是的图像的字节流.查看帮助,有输出字节流的方式,首先定义一个MemBlock对象,用来存字节流
MemBlock image;
然后
image=c->makeChart(JPG);
来生成JPG图像
3,现在输出到web
printf("Content-Type: image/*\n\n");//告诉浏览器输出格式
_setmode(_fileno(stdout), _O_BINARY);//设置stdout为二进制
_setmode(_fileno(stdout), _O_BINARY);//设置stdout为二进制
fwrite(image.data,1,image.len,stdout);//输出
在网页中
<img src="xx.cgi">
就行了