views:

1342

answers:

2

Hi,

I need to transmit the image from the mobile phone to the server. I am able to reduce the image screen size but not the memory size. I understand i have to deal with the color depth. J2ME does not seem to offer any scaling method which is available in J2SE:

image rescaled = image.getScaledInstance(thumbWidth, thumbHeight,  Image.SCALE_AREA_AVERAGING);
BufferedImage biRescaled = toBufferedImage(rescaled, thumbWidth, thumbHeight, BufferedImage.TYPE_INT_RGB);

How i would i tackle this ? I would like to reduce the image memory size before i transmit to the server. Thank you

A: 

Take a look to this (GEAR Java Mobile Framework). There is an utility package with a class named ImageHelper. It contains some methods to scale an image and thus reduce it's size. It works good on mobile devices and it's reasonably fast to execute. If your image is still a big one or you don't want to loose too much data, consider using a compression algorithm. zlib offers a very good solution and there's an implementation for J2ME ready to be used.

Stefano Driussi
A: 

Hi,

I am facing the same problem. My application needs to send the images captured from phone to a server, but the user wants to preview the image before sending (through the app and not through the gallery). Previously, I was testing on N95 and I could retrieve the thumbnails for the user preview but the thumbnails seem to be unavailable for N86 and ExpressMusic devices. Are thumbnails available on these devices?

The other problem is, that I am using the GEAR's ImageHelper class to compress the image, but since the image is too huge, it is not working. I have never tried using a compression algorithm. Also, since I am obtaining the image from a FileConnection, I can get it as an array of bytes[]. Is there any way to play around with this array to get a compressed array (e.g. just taking every fourth byte (or every fourth set of four bytes) from the array) and still be able to obtain an image from it?

Your kind input would be very much appreciated on any of these issues.

Thanks and regards, Ashish.