gpt4 book ai didi

blackberry - 我如何在 Blackberry 中设置背景图像?

转载 作者:行者123 更新时间:2023-12-02 02:19:35 25 4
gpt4 key购买 nike

我想在垂直领域管理器中设置背景图像。我试过了,但它没有填充高度,你可以在我的屏幕上看到它。并在我的代码中关注我做错了什么,请帮助我。

 vfmCenter = new VerticalFieldManager(FIELD_HCENTER)
{
public void paint(Graphics graphics)
{

graphics.clear();
graphics.drawBitmap(0, 0,deviceWidth,deviceHeight,newimg,0,0);
super.paint(graphics);
}

protected void sublayout( int maxWidth, int maxHeight)
{
int width = Display.getWidth();
int height = Display.getHeight();
super.sublayout( width, height);
setExtent( width, height);
}
};

vfmMain.add(vfmCenter);
this.add(vfmMain);

enter image description here

最佳答案

我之前也遇到过同样的问题..我用这个解决了我的问题..

class MyClass extends MainScreen
{
// function for scaling your image to fit the screen

public EncodedImage scaleImage(EncodedImage source, int requiredWidth, int requiredHeight)
{
int currentWidthFixed32 = Fixed32.toFP(source.getWidth());
int requiredWidthFixed32 = Fixed32.toFP(requiredWidth);
int scaleXFixed32 = Fixed32.div(currentWidthFixed32, requiredWidthFixed32);
int currentHeightFixed32 = Fixed32.toFP(source.getHeight());
int requiredHeightFixed32 = Fixed32.toFP(requiredHeight);
int scaleYFixed32 = Fixed32.div(currentHeightFixed32, requiredHeightFixed32);
return source.scaleImage32(scaleXFixed32, scaleYFixed32);
}
public MyClass
{
ei = EncodedImage.getEncodedImageResource("res/background_image");
ei1= scaleImage(ei,requires_width,required_height);
vfm= new VerticalFieldManager(VerticalFieldManager.USE_ALL_HEIGHT|VerticalFieldManager.USE_ALL_WIDTH);
vfm.setBackground(BackgroundFactory.createBitmapBackground(ei1.getBitmap()));
vfm.add(new LabelField("hello notice the background behind me");
add(vfm);
}
}

试试这个。我认为它对你有用!!

关于blackberry - 我如何在 Blackberry 中设置背景图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8937175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com