I tested the new Camera2 API on Android Lollipop. I want to get a supported preview size:
StreamConfigurationMap streamConfigurationMap = cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); Size[] sizes = streamConfigurationMap.getOutputSizes(SurfaceTexture.class);
and the maximum preview size is 1440x1080 pixels on the Samsung Galaxy Tab S with a resolution of 2560x1600 pixels. So my preview size is 1440x1080 pixels, and the size of the TextureView surface is 2560x1600 pixels, so the image is distorted.
I tested the old camera API, which is deprecated.
Camera.Parameters parameters = camera.getParameters(); List<Camera.Size> sizes = parameters.getSupportedPictureSizes();
And the above code returns 32 preview size options, such as: 2560x1920 , 1920x1080 , 1080x1920 , 2560x2560 , etc. In this case, I can choose the optimal size and display the correct image.
I do not know how to get the new API to get the optimal size. I know that the solution is to resize the view down, which displays a preview, but the cameraβs built-in application works in full screen mode. Thanks in advance for all the suggestions!
source share