如何在blackberry应用程序中设置背景图像适配
我在这里编写了以下代码,背景图像正在显示,但图像没有覆盖整个背景如何在blackberry应用程序中设置背景图像适配,blackberry,blackberry-eclipse-plugin,blackberry-jde,Blackberry,Blackberry Eclipse Plugin,Blackberry Jde,我在这里编写了以下代码,背景图像正在显示,但图像没有覆盖整个背景 私有位图背景; int mWidth=Display.getWidth(); int mHeight=Display.getHeight(); 公共MyScreen() { //设置屏幕显示的标题 //backgroundBitmap=Bitmap.getBitmapResource(“slideImage.png”); 最终位图背景=Bitmap.getBitmapResource(“slideImage.png
私有位图背景;
int mWidth=Display.getWidth();
int mHeight=Display.getHeight();
公共MyScreen()
{
//设置屏幕显示的标题
//backgroundBitmap=Bitmap.getBitmapResource(“slideImage.png”);
最终位图背景=Bitmap.getBitmapResource(“slideImage.png”);
HorizontalFieldManager vfm=新的HorizontalFieldManager(使用所有高度、使用所有宽度){
公共空间涂料(图g){
g、 drawBitmap(0,0,mWidth,mHweight,background,0,0);
超级油漆(g);
}
};
添加(vfm);
可以使用上述方法调整图像的大小
只需传递要调整大小的图像及其宽度和高度。
函数将返回调整大小的图像
其中,重缩放数组是下面的方法
private static int[] rescaleArray(int[] ini, int x, int y, int x2, int y2)
{
int out[] = new int[x2*y2];
for (int yy = 0; yy < y2; yy++)
{
int dy = yy * y / y2;
for (int xx = 0; xx < x2; xx++)
{
int dx = xx * x / x2;
out[(x2 * yy) + xx] = ini[(x * dy) + dx];
}
}
return out;
}
私有静态int[]重缩放数组(int[]ini,int x,int y,int x2,int y2)
{
int out[]=新的int[x2*y2];
for(int-yy=0;yy
您需要在绘制之前缩放(拉伸)位图。请检查此答案,.公共静态位图resizeImage()
将解决您的问题。另外,请阅读API文档。
private static int[] rescaleArray(int[] ini, int x, int y, int x2, int y2)
{
int out[] = new int[x2*y2];
for (int yy = 0; yy < y2; yy++)
{
int dy = yy * y / y2;
for (int xx = 0; xx < x2; xx++)
{
int dx = xx * x / x2;
out[(x2 * yy) + xx] = ini[(x * dy) + dx];
}
}
return out;
}