uestccokey / EZFilter

A lightweight (<180KB), easy-to-extend Android filter and dynamic sticker framework for adding filters and stickers for camera, video, bitmap and view.(一个轻量级(<180KB)、易扩展的Android滤镜和动态贴纸框架,支持摄像头、视频、图片和视图添加滤镜和贴纸。)
MIT License
208 stars 57 forks source link

Landscape Camera - Stretching issue #30

Closed mangoxxx closed 6 years ago

mangoxxx commented 6 years ago

When i am trying to use camera1 in landscape mode then view is stretching . Please check this asap

uestccokey commented 6 years ago

you can fix it by add "mRenderView.setRotate90Degrees(1);" such as

private void setCameraParameters() {
        Camera.Parameters parameters = mCamera.getParameters();
        if (getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
            Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
            Camera.getCameraInfo(mCurrentCameraId, cameraInfo);

            parameters.set("orientation", "portrait");
            int orientation;
            if (mCurrentCameraId == Camera.CameraInfo.CAMERA_FACING_FRONT) {
                parameters.set("rotation", 270);
                orientation = 360 - cameraInfo.orientation;
            } else {
                parameters.set("rotation", 90);
                orientation = cameraInfo.orientation;
            }
            mCamera.setDisplayOrientation(orientation);

            mRenderView.setRotate90Degrees(0);
        } else {
            parameters.set("orientation", "landscape");
            mCamera.setDisplayOrientation(0);

            mRenderView.setRotate90Degrees(1);
        }

        // 预览分辨率设置为1280*720
        parameters.setPreviewSize(1280, 720);

        // 输出分辨率设置为1280*720,质量100%
        parameters.setPictureSize(1280, 720);
        parameters.setJpegQuality(100);

        // 设置自动闪光灯
        List<String> flashModes = parameters.getSupportedFlashModes();
        if (flashModes != null && flashModes.contains(Camera.Parameters.FLASH_MODE_AUTO)) {
            parameters.setFocusMode(Camera.Parameters.FLASH_MODE_AUTO);
        }

        // 设置自动对焦
        List<String> focusModes = parameters.getSupportedFocusModes();
        if (focusModes != null && focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
            parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
        }

        mCamera.setParameters(parameters);
    }

Thank you for your feedback!

uestccokey commented 6 years ago

@mangoxxx

mangoxxx commented 6 years ago

Thankyou so much @uestccokey

mangoxxx commented 6 years ago

For landcape - I am using

parameters.set("orientation", "landscape"); mCamera.setDisplayOrientation(0); mRenderView.setRotate90Degrees(1);

But When i am switching camera then it is rotating camera preview.

Please Help

jackaru commented 6 years ago

When you switch camera you can mRenderView.setRotate90Degrees(0); or any rotation you want

jackaru commented 6 years ago

@mangoxxx Change activity orientation on manifest, 100% works