1

I have written the following code to add image as a background to the BlackBerry screen.The image size is 320*240.The image is added to the screen but then I want to increase its height and width according to the size of the BB screen height and width.

Following is the code I have written:

Bitmap xtclogoBitmap = Bitmap.getBitmapResource("launch_xtc.jpg");
BitmapField xtcbitmapField = new BitmapField(xtclogoBitmap,Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH);
add(xtcbitmapField);

How can I increase the height and width of the image as per the BB screen size?

Piskvor left the building
  • 91,498
  • 46
  • 177
  • 222
user469999
  • 2,101
  • 4
  • 24
  • 30
  • possible duplicate of [Blackberry - how to resize image?](http://stackoverflow.com/questions/1769755/blackberry-how-to-resize-image) – Michael Donohue Dec 20 '10 at 14:04

1 Answers1

1
Bitmap img=Bitmap.getBitmapResource("3.jpg");
Bitmap bg = new Bitmap(Display.getWidth(), Display.getHeight());
img.scaleInto(bg,Bitmap.FILTER_LANCZOS, Bitmap.SCALE_TO_FILL);

you can replace Bitmap.SCALE_TO_FILL and/or modify the values of getheight and width by addition for example depending on your needs, then just add the bg

check this explanation from BlackBerry here

regards,

CME64
  • 1,673
  • 13
  • 24