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
Contributor
Posts: 24
Registered: ‎07-08-2010
My Device: Blackberry 9000
Accepted Solution

Re-size Encoded Images before Adding it to a BitmapField

I am having issues re-sizing my image. I click an image using the camera and store it in the pictures folder. When I retrieve the image I see the image on the screen but I want it to be smaller since it occupies the entire screen and more and I have to scroll down. I added the code to scaleImage, (see the red coded linebelow) but no luck. Am I doing something wrong? - Thank you.

 

 

EncodedImage image = EncodedImage.createEncodedImage(dataArray, 0, dataArray.length

image.scaleImage32(1, 1);

 

BitmapField bitmapField = new BitmapField();

bitmapField.setImage(image);

 

add(bitmapField);

 

Developer
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: Re-size Encoded Images before Adding it to a BitmapField

scaleImage32 used a Fixed32 number. This means you either need to called Fixed32.toFP(*num*) or the code equivilant which is *num* * 65536 (0x10000).

 

The documentation should explain it pretty well.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Contributor
Posts: 24
Registered: ‎07-08-2010
My Device: Blackberry 9000

Re: Re-size Encoded Images before Adding it to a BitmapField

I changed the image.scaleImage32(1,1) to image.scaleImage32(100,100) and still no luck. Maybe I dont understand how scaling works. I thought the bigger the number the smaller the size. Any thoughts would be appreciated. Thanks.

Contributor
Posts: 24
Registered: ‎07-08-2010
My Device: Blackberry 9000

Re: Re-size Encoded Images before Adding it to a BitmapField

sorry, I was reading the document as you wrote a reponse. I still can't figure it out, I want to reduce the image to 50% of it's size. I dont know how to call Fixed32.toFP(), is that a function call in the image? - Thanks for your time.

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

Re: Re-size Encoded Images before Adding it to a BitmapField

Take a look at net.rim.device.api.math.Fixed32.  Or, when you read documentation on encodedImage.scaleImage32, click on one of the Fixed32 links (should be easy :smileyhappy: ).

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Contributor
Posts: 24
Registered: ‎07-08-2010
My Device: Blackberry 9000

Re: Re-size Encoded Images before Adding it to a BitmapField

fixed32.tofp did it. thanks