I am trying to get a full screen preview of the camera. I read through the documentation of camera2 which says Each Surface has to be pre-configured with an appropriate size and format (if applicable) to match the sizes and formats available from the camera device.
Here is what I understand so far. Please correct me if any of my understanding is wrong:
The texture view and the preview buffer need to be the same aspect ratio. They can be different resolutions, but the aspect ratio must be the same if you don't want the preview to look distorted.
You should set the buffer size of the texture view to the optimally chosen preview size. camera2basic demo seems to confirm this with the line
texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()
.
The question I have is, once you match the aspect ratio and size of the texture view and the preview to be the same, how do you scale the texture view so that it fits fullscreen?
The camera2basic demo's configureTransform
method seems to transform the TextureView to the preview size, but not make it full screen. How do I calculate the correct scale factor to make TextureView fullscreen?