Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 37
Registered: ‎10-06-2008
My Device: Not Specified

Resizing a jpeg without decoding

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 ...

 

Thanks!

Andy

Developer
Posts: 5,339
Registered: ‎09-20-2008
My Device: ***
My Carrier: ***

Re: Resizing a jpeg without decoding

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.

 

Developer
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: Resizing a jpeg without decoding

here is some info,

http://en.wikipedia.org/wiki/JPEG

 

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.

 

New Developer
Posts: 17
Registered: ‎12-05-2008
My Device: Not Specified

Re: Resizing a jpeg without decoding

I think JPEGEncodedImage class might be help you.

 

vi-chat, chat yahoo on blackberry! www.en.vi-chat.com
New Developer
Posts: 37
Registered: ‎10-06-2008
My Device: Not Specified

Re: Resizing a jpeg without decoding

Hi nghienpc,

 

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.

 

Andy

Developer
Posts: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

Re: Resizing a jpeg without decoding

Have you been able to solve this problem?  

 

I'm also trying to retrieve the image data of a scaled down image.

 

Earl 

Earl Oliver
Highlighted
Developer
Posts: 25
Registered: ‎10-22-2009
My Device: Not Specified

Re: Resizing a jpeg without decoding

 


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)

in JPegEncodedImage

No?

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?