android.Camera.Preferences.setRotation 文档
public void onOrientationChanged(int orientation) {
if (orientation == ORIENTATION_UNKNOWN) return;
android.hardware.Camera.CameraInfo info =
new android.hardware.Camera.CameraInfo();
android.hardware.Camera.getCameraInfo(cameraId, info);
orientation = (orientation + 45) / 90 * 90;
int rotation = 0;
if (info.facing == CameraInfo.CAMERA_FACING_FRONT) {
rotation = (info.orientation - orientation + 360) % 360;
} else { // back-facing camera
rotation = (info.orientation + orientation) % 360;
}
mParameters.setRotation(rotation);
}
API 级别 5(或更好甚至 4)中是否有 Camera.CameraInfo 的替代方案?我正在尝试设置捕获图像的旋转,但我无法弄清楚如何获取设备相机的方向。API 级别 9 之前的所有相机的方向都是固定的还是什么?