Page 1 of 1

Unable to convert jfreechart to jpeg image

Posted: Wed Apr 29, 2009 4:40 pm
by Buddy
hi,
I was using jfreechart-1.0.1.jar in my application for plotting a chart. After that, the chart is converted to jpeg image for display. The code snippet used for this purpose was:

BufferedImage bufImage = chart.createBufferedImage(800, 425, null);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder( response.getOutputStream() );
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam( bufImage );
param.setQuality( 0.75f, true );
encoder.encode( bufImage, param );
ImageIO.write ( bufImage,"jpeg",out );

Now I have updated the jfreechart to 1.0.13 version.But the above mentioned code snippet is not working i.e, image is not displaying.. Tried by changing the image format to .png and now the image is displaying.Can anyone help on this please?

Re: Unable to convert jfreechart to jpeg image

Posted: Mon May 04, 2009 9:41 am
by Buddy
By using the below line of code instead of the above block of code, the chart image is getting displayed.

ChartUtilities.writeChartAsJPEG(response.getOutputStream(), 0.75f,vitalsChart, 800, 425)

I am using java6,jfreechart1.0.13 and jcommon-1.0.16. Can anyone help on this issue please?One thing noted is,APIs using bufferredimage is not working.