mrmoment
mrmoment

Reputation: 757

Get and show partial area of camera view in Android

I use following codes to take pictures from the camera view.

captureButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {        
        mCamera.autoFocus(new AutoFocusCallback() {                    
            @Override
            public void onAutoFocus(boolean success, Camera camera) {                  
               mCamera.takePicture(null, null, mPicture);
            }
        });
    }
});

Instead of asking users to shoot a picture, now I need to continuously show a smaller part (e.g., 50% width) of the camera picture directly to a view (e.g., ImageView).

How can I get the current content from the camera and operate to get a part of it? I need a fast way, so as to be in a video streaming manner (better if I could directly realize this by some codes with the SurfaceHolder preview configuration).

Upvotes: 1

Views: 308

Answers (1)

Jago
Jago

Reputation: 155

I don't know if I understand you correctly. You could use a custom view extending SurfaceView to get and show the camera preview (something like this, you will probably have to play around with some parameters). Then you could place that view on your layout.

Upvotes: 1

Related Questions