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
Highlighted
Developer
Posts: 242
Registered: ‎02-19-2013
My Device: 9500
My Carrier: _
Accepted Solution

How to set the bitmap width as mobile size dynamically and adjust photo accordingly.

I have bitmap. Now I want to set the bitmap on screen but its size should be as mobile width and adjust photo accordingly. For ex I have large image it should look like small in small screen mobile.

 

My code but its not working.    

 

public static BitmapField getHeader() throws NullPointerException {
        Bitmap b = Bitmap.getBitmapResource("img/logo.jpg");
        return (new BitmapField(b, Field.FIELD_HCENTER) {
            protected void layout(int width, int height) {
                setExtent(365, 80);
            }
        });
    }

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to set the bitmap width as mobile size dynamically and adjust photo accordingly.

You will have to scale the image yourself to match the dimensions that you need.

 

Look at Bitmap.scaleInto()

 

If you have transparent images, then look at this:

http://supportforums.blackberry.com/t5/Java-Development/Resizing-Transparent-Bitmaps/ta-p/703239