Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nexus 5x 相机预览画面反了 #9

Open
xianchuangwu opened this issue Feb 21, 2017 · 1 comment
Open

nexus 5x 相机预览画面反了 #9

xianchuangwu opened this issue Feb 21, 2017 · 1 comment

Comments

@xianchuangwu
Copy link

xianchuangwu commented Feb 21, 2017

我设置theCamera.setDisplayOrientation(90);也不起作用,不知道为什么

@xianchuangwu xianchuangwu changed the title 相机预览画面反了 nexus 5x 相机预览画面反了 Feb 21, 2017
@magiclonw
Copy link

    CameraInfo info = new CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    int degree = 0;
    switch (rotation) {
        case Surface.ROTATION_0:
            degree = 0;
            bSreenMirror = true;
            break;
        case Surface.ROTATION_90:
            degree = 90;
            bSreenMirror = false;
            break;
        case Surface.ROTATION_180:
            degree = 180;
            bSreenMirror = false;
            break;
        case Surface.ROTATION_270:
            degree = 270;
            bSreenMirror = true;
            break;
    }
   
    int result;
    if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degree) % 360;
        result = (360 - result) % 360; // compensate the mirror
    } else { // back-facing
        result = (info.orientation - degree + 360) % 360;
    }
    mCamera.setDisplayOrientation(result);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants