Reputation: 347
i am trying to set background image for Blackberry 9900 simulator, i have written code like below
BitmapField _bitmap ;
private int phoneWidth = Display.getWidth();
private int cellHeight = Display.getHeight();
public MyScreen(){
super(Manager.USE_ALL_WIDTH | Manager.NO_VERTICAL_SCROLL);
final Bitmap background = Bitmap.getBitmapResource("black.jpg");
VerticalFieldManager vfm = new VerticalFieldManager(USE_ALL_HEIGHT | USE_ALL_WIDTH) {
public void paint(Graphics g) {
Bitmap scaled = new Bitmap(phoneWidth, cellHeight);
background.scaleInto(scaled, Bitmap.SCALE_TO_FIT);
g.drawBitmap(0, 0, phoneWidth, cellHeight,
background, 0, 0);
super.paint(g);
}
};
add(vfm);
}
and iam getting output in simulator like this
i want the background image to fill complete background, any help will be appreciated, Thank u in advance.
Upvotes: 1
Views: 171
Reputation: 308
Problem is HERE
g.drawBitmap(0, 0, phoneWidth, cellHeight,
background, 0, 0);
you must draw scaled bitmap
g.drawBitmap(0, 0, phoneWidth, cellHeight,
scaled , 0, 0);
Upvotes: 3