0

Hello,

In my application I transfer a lot of images from server to client. The problem is the size of the image, so I tried to encode it using this encoder - objectplanet png encoder. The problem is nothing seems to happen, image size is the same.

//img is a BufferedImage object
 PngEncoder pngenc;
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
pngenc.setCompression(PngEncoder.COLOR_GRAYSCALE_ALPHA);//this doesn't seem to work
pngenc.encode(img, baos);//write encoded image to stream... not working?
             
            baos.flush();

Does anybody knows why is not compressing the image? ...and is PNG the best transfer option? (for speed)

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Clawsy
0

This is just a guess, but... you have
PngEncoder pngenc;
that creates a reference variable, but it does NOT give you a PngEncoder object. Y0u probably need something like
PngEncoder pngenc = new PngEncoder();

0

I did it... sorry it is missing from my code but I did create the object.

Edited by Clawsy: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.