Camera in Android, how to get best size, preview size, picture size, view size, image distorted

后端 未结 3 1367
不思量自难忘°
不思量自难忘° 2020-11-30 02:16

having image distorted when mixing a view from OpenGL and the Android camera to get an image of both when using the takepicture method. I checked and found that the camera

3条回答
  •  既然无缘
    2020-11-30 02:31

    I think the best way to get preview size, picture size is the Camera was set up to support all Android devices. It means the preview size, picture size you decide to set up is appropriate with the popular format that All Devices supported, ex. is 1280x720 etc.

    As in following codes, is the ex. what I used.

    // start preview with new settings
        try {
            // set preview size and make any resize, rotate or
            // reformatting changes here
            Camera.Parameters parameters = mCamera.getParameters();
    
            for (Camera.Size size : parameters.getSupportedPictureSizes()) {
                // 640 480
                // 960 720
                // 1024 768
                // 1280 720
                // 1600 1200
                // 2560 1920
                // 3264 2448
                // 2048 1536
                // 3264 1836
                // 2048 1152
                // 3264 2176
                if (1600 <= size.width & size.width <= 1920) {
                    parameters.setPreviewSize(size.width, size.height);
                    parameters.setPictureSize(size.width, size.height);
                    break;
                }
            }
            // Set parameters for camera
            CustomCamera.mCamera.setParameters(parameters);
    
            Camera.Size size = CustomCamera.mCamera.getParameters().getPictureSize();
    
            mCamera.setPreviewDisplay(mHolder);
            mCamera.startPreview();
        } catch (Exception e) {
            e.printStackTrace();
        }
    

    Best size depend on Camera MP. So I think should use default if using Camera.

提交回复
热议问题