Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 31
Registered: ‎08-26-2011
My Device: Torch 9810
My Carrier: AT&T
Accepted Solution

Superimpose a box over the video field

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);
	}

 

 

Contributor
Posts: 31
Registered: ‎08-26-2011
My Device: Torch 9810
My Carrier: AT&T

Re: Superimpose a box over the video field

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.

 

Highlighted
BlackBerry Development Advisor
Posts: 15,252
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Superimpose a box over the video field

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.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
Posts: 31
Registered: ‎08-26-2011
My Device: Torch 9810
My Carrier: AT&T

Re: Superimpose a box over the video field

Thanks for pointing me in the right direction.