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: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon
Accepted Solution

thumbnail from byte[]

How can I generate a thumbnail from a byte[] - not from an image file?

I store images in data store & want to create a thumbnail directly from the byte[] data.

thanks

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: thumbnail from byte[]

Take a look at Bitmap.createBitmapFromBytes(...) http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/Bitmap.html#createBitma...

Looks like it should do exactly what you want as long as you know the full size of the image already, or don't care to have all of the thumbs be the same size.

New Developer
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: thumbnail from byte[]

Thanks.

I'm looking for a way to create a small image size, like png icon.

When I create the bitmap it's still the same size as the original.

How to create a 125x125 pixel image that's low density?

 

Developer
Posts: 2,268
Registered: ‎07-08-2009
My Device: various
My Carrier: various

Re: thumbnail from byte[]

Take a look at this post:

Resizing bitmap without creating encoded image

 

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
New Developer
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: thumbnail from byte[]

Thanks.

I have a byte[] that contains my bmp.

the bmp is 2048x1536 & when I save it to sd card it's 390kb.

How can I take the byte[] & create a bmp that's only 200x200?

 

New Developer
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: thumbnail from byte[]

sorry, correction:

How can I take the byte[] & create another byte[] whose bmp will be only 200x200?

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: thumbnail from byte[]

Did you try modifying the "scale" argument of createBitmapFromBytes?

New Developer
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: thumbnail from byte[]

yes. that works but I'm stuck on getting the new, smaller bitmap to byte[].

i.e., I can scale it, view it etc. but can't get it back to byte[] to save.

thanks

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

Re: thumbnail from byte[]

getARGB() would probably work.

 

One other thing you can do is :

 

JPEGEncodedImage jpg = JPEGEncodedImage.encode(scaledBMP, 100);

byte[] data = jpg.getData();

 

PNGEncodedImage has that too.

 

Then you'd be storing as a jpg or png.

 

New Developer
Posts: 137
Registered: ‎02-04-2010
My Device: Tour 9630
My Carrier: verizon

Re: thumbnail from byte[]

Excellent.

Thank you all for your help.