08-24-2012 01:53 PM
I am trying to create a transparent box in the center of my camera video screen to assist in aiming.
I have tried overriding the paint subroutine to create the box as in the code below; however, it is not working.
public void paint(Graphics g)
{
super.paint(g);
Bitmap bmpAimer = new Bitmap(50, 50);
g.drawBitmap(0, 0, bmpAimer.getWidth(), bmpAimer.getHeight(), bmpAimer, 100, 150);
}
Solved! Go to Solution.
08-28-2012 04:15 PM
I changed my code to use a transparent image and use the AbsoulteFieldManager's paint method to display the image, however, it is still overlaid by the video field.
AbsoluteFieldManager _afm;
static EncodedImage bmpAimer = EncodedImage.getEncodedImageResource("target.png") ;
_afm = new AbsoluteFieldManager() {
//Override the paint method to draw the target image.
public void paint(Graphics graphics) {
super.paint(graphics);
graphics.drawImage(
Display.getWidth() / 2 - bmpAimer.getWidth() / 2, Display.getHeight() / 2 - bmpAimer.getHeight() / 2,
bmpAimer.getWidth(), bmpAimer.getHeight(),
bmpAimer, 0, 0, 0
);
}
};
if(_videoField != null)
{
_afm.add(_videoField);
add(_afm);
this.addKeyListener(new MyKeyListener());
}
Any help would be appreciated.
08-29-2012 10:57 AM
You need to use ComponentCanvas to draw on top of video. The nativewindowmanagerdemo included with the version 7.0 and higher BlackBerry Java SDK demonstrates how to do this.
08-30-2012 08:44 AM
Thanks for pointing me in the right direction.