Servlet png images

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Achilleus Mantzios

Servlet png images

Post by Achilleus Mantzios » Wed Dec 19, 2001 9:43 am

I think png charts are better than jpeg,
lossless, and smaller.

Here is the code changes in your servlet (you need to install jai first)

import com.sun.media.jai.codecimpl.*;
import com.sun.media.jai.codec.*;



PNGEncodeParam$RGB param = new PNGEncodeParam.RGB();
PNGImageEncoder encoder = new PNGImageEncoder(out,param);
encoder.encode(img);

Cheers

David Gilbert

RE: Servlet png images

Post by David Gilbert » Thu Dec 20, 2001 9:26 am

Hi Achilleus,

Thanks for your post. I agree that PNG is a better encoding for charts.

I haven't tried the encoder that you suggest - I've just been using the open source one written by J. David Eisenberg, it's LGPL so I've included it in the JCommon Class Library. I don't use the encoder in a server environment, so I haven't really looked closely at whether or not it is efficient. But the source code is there, so if it needs improving, there's no problem...

Regards,

DG.

Locked