Chickin Nick Chickin Nick - 8 months ago 252
Android Question

Camera 2 Api preview is stretched

I work with old camera api and camera 2 api, using GlSurfaceView.
when I get necessary aspect ratio in old api I use

camParams.setPreviewSize(previewW, previewH);
if(isPictureSizeSupported(camParams, newSize)) {
camParams.setPictureSize(newSize.getWidth(), newSize.getHeight());

if it will not be called, preview is streched

Q: How to get such effect in camera 2 api?


I migrate to SurfaceView and used setFixedSize() on SurfaceHolder. As Documentation says:

For drawing to a SurfaceView: Once the SurfaceView's Surface is created, set the size of the Surface with setFixedSize(int, int) to be one of the sizes returned by getOutputSizes(SurfaceHolder.class) and then obtain the Surface by calling getSurface()