Open xianchuangwu opened 7 years ago
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);
我设置theCamera.setDisplayOrientation(90);也不起作用,不知道为什么