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
Highlighted
Contributor
Posts: 44
Registered: ‎02-21-2011
My Device: Playbook
My Carrier: N/A

Disable AutoFocus

In my app I am taking a picture by using.

 

VideoControl.getSnapshot()

 

My problem is that the Camera always autofocuses before taking the picture (it won't take a picture until the focus rectangle is green). Is there a way to override the autofocus? I have tried using

 

EnhancedFocusControl.stopAutoFocus();

 

but this doesn't seem to be working for me.

 

 

Here are the relevent parts of my code;

 

private void initializeCamera()
    {
        try
        {
            Player player = Manager.createPlayer( "capture://video" );
            player.realize();
            _videoControl = (VideoControl)player.getControl( "VideoControl" );

            if (_videoControl != null)
            {
                
                _videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                _videoControl.setDisplayFullScreen(true);
                _videoControl.setVisible(true);
            }

            player.start();
            
            
            _efc = (EnhancedFocusControl)player.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
            }

 catch(Exception e)
        {
            CameraDemo.errorDialog("ERROR " + e.getClass() + ":  " + e.getMessage());
        }
    }



///And the function for taking the photo


 public void takePicture()
    {
        try
        {
                   
            _efc.stopAutoFocus();
            Bitmap image = Bitmap.createBitmapFromBytes( _videoControl.getSnapshot( null ), 0, -1, IMAGE_SCALING );

          }
            
			
        }
        catch(Exception e)
        {
            CameraDemo.errorDialog("ERROR " + e.getClass() + ":  " + e.getMessage());
        }
    }
            

 

-------------------------------------------------------------------------------------------

Check out MyBestShot for the playbook in Blackberry Appworld.