01-02-2009 02:47 PM
My application uploads images taken by the camera over HTTP. I want to reduce the bandwidth used by scaling the images down before upload. Its unclear how I can do this. I've used EncodedImage.scaleImage32 before but it only scales the image when it is decoded from jpg to Bitmap. In this case, I don't care about decoding the image because I want to upload it in jpg format anyway. Does anyone know how I can resize a jpg and keep the result encoded as a jpg? Even if I used EncodedImage to resize on decode, its not clear if there is a way to re-encode the Bitmap back to jpg ...
01-03-2009 06:53 AM
Actually I have no information regarding your particular question.
Try to use ZLibOutputStream for output activities.
Image in JPEG format is already compressed but let's try to use this stream class for scaled bitmap images.
01-04-2009 11:10 AM
here is some info,
if you can get it as a byte array maybe you can do something to toss out stuff you don't need
but I'm not sure if the java code would be any faster than the library code that is probably native.
You would need to do something with the DCT coefficients and deal with the various tables.
01-08-2009 09:11 AM
JPEGEncodedImage is a subclass of EncodedImage that handles decoding. As I mentioned above, what I really want to do is scale the image down and get the results in a JPEG. From what I can see in the javadoc, EncodedImages only support scaling during the decoding process from JPEG to Bitmap. This would work if there was a way to turn the Bitmap back into a JPEG. Unfortunately, I don't know of a way to do this.
04-22-2010 07:43 PM
joven wrote:This would work if there was a way to turn the Bitmap back into a JPEG. Unfortunately, I don't know of a way to do this.
public static JPEGEncodedImage encode(Bitmap bitmap, int quality)
It's not a great solution but it seems to work. The results are crappy though. Is there a way to manipulate sizes and quality inside jpeg only without going out to bitmap?