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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Contributor
mohunt
Posts: 29
Registered: ‎08-26-2011
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);
	}

 

 

Please use plain text.
Contributor
mohunt
Posts: 29
Registered: ‎08-26-2011
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.

 

Please use plain text.
Administrator
MSohm
Posts: 12,957
Registered: ‎07-09-2008
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.
Found a bug? Report it using the Issue Tracker
Please use plain text.
Contributor
mohunt
Posts: 29
Registered: ‎08-26-2011
My Carrier: AT&T

Re: Superimpose a box over the video field

Thanks for pointing me in the right direction.

Please use plain text.