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
Servlet png images
RE: Servlet png images
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.
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.