Unable to convert jfreechart to jpeg image

A free public discussion forum for JFreeDesigner, a report definition designer for JFreeReport.
Locked
Buddy
Posts: 5
Joined: Fri Apr 24, 2009 7:54 am

Unable to convert jfreechart to jpeg image

Post by Buddy » Wed Apr 29, 2009 4:40 pm

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?

Buddy
Posts: 5
Joined: Fri Apr 24, 2009 7:54 am

Re: Unable to convert jfreechart to jpeg image

Post by Buddy » Mon May 04, 2009 9:41 am

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.

Locked