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)

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();

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.