2016-04-15

How can we adjust the size of Android Camera Preview on the Screen


In this Android Camera test example, we will see the full screen preview view on the screen.
However, we can not set arbitrary camera size we want. We can only select one of the sizes returned from getSupportedPreviewSizes call, like:

    mSupportedPreviewSizes = mCamera.getParameters().getSupportedPreviewSizes();

And later we set the Preview size with the call setPreviewSize() in the surfaceChanged method:
    parameters.setPreviewSize(mPreviewSize.width, mPreviewSize.height);

We can not set any other values. Otherwise the app will generate error.

Then, How can we adjust the size of Camera Preview on the Screen if we don't any of the Supported Preview Sizes?

Simple! Since we cannot change the input of the surface View, but we change the
surface View output. We can adjust  the size of the surface View to any value as we wish.


Reference:

josnidhin/Android-Camera-Example

沒有留言:

張貼留言