根据BB屏幕尺寸增加图像的高度 [英] Increase the height widht of image as per BB screen size
问题描述
我编写了以下代码,将图像作为背景添加到BlackBerry屏幕。图像大小为320 * 240.图像被添加到屏幕但我想根据大小增加其高度和宽度BB屏幕的高度和宽度。
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.
以下是我写的代码:
Bitmap xtclogoBitmap = Bitmap.getBitmapResource("launch_xtc.jpg");
BitmapField xtcbitmapField = new BitmapField(xtclogoBitmap,Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH);
add(xtcbitmapField);
如何根据BB屏幕尺寸增加图像的高度和宽度?
How can I increase the height and width of the image as per the BB screen size?
推荐答案
Bitmap img=Bitmap.getBitmapResource("3.jpg");
Bitmap bg = new Bitmap(Display.getWidth(), Display.getHeight());
img.scaleInto(bg,Bitmap.FILTER_LANCZOS, Bitmap.SCALE_TO_FILL);
您可以替换Bitmap.SCALE_TO_FILL和/或通过添加来修改getheight和width的值,例如具体取决于根据您的需求,然后只需添加bg
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
从BlackBerry 这里
check this explanation from BlackBerry here
问候,
这篇关于根据BB屏幕尺寸增加图像的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!