From c1dd72054122befb49aa1ca11ffa589b00186f80 Mon Sep 17 00:00:00 2001 From: Wu-cheng Li Date: Mon, 18 Oct 2010 19:37:45 +0800 Subject: Fix wrong usage of setRotation and setOrientation. bug:3105659 Change-Id: Ie2c1559cc03ece66705c1d766bea0e736f2684bc --- src/com/android/camera/Util.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/com/android/camera/Util.java') diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java index adf9152..d5cd768 100644 --- a/src/com/android/camera/Util.java +++ b/src/com/android/camera/Util.java @@ -22,6 +22,7 @@ import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; +import android.hardware.Camera; import android.util.Log; import android.view.Surface; import android.view.View; @@ -293,12 +294,19 @@ public class Util { } public static void setCameraDisplayOrientation(Activity activity, - int cameraId, android.hardware.Camera camera) { - android.hardware.Camera.CameraInfo info = - new android.hardware.Camera.CameraInfo(); - android.hardware.Camera.getCameraInfo(cameraId, info); + int cameraId, Camera camera) { + // See android.hardware.Camera.setCameraDisplayOrientation for + // documentation. + Camera.CameraInfo info = new Camera.CameraInfo(); + Camera.getCameraInfo(cameraId, info); int degrees = getDisplayRotation(activity); - int result = (info.orientation - degrees + 360) % 360; + int result; + if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { + result = (info.orientation + degrees) % 360; + result = (360 - result) % 360; // compensate the mirror + } else { // back-facing + result = (info.orientation - degrees + 360) % 360; + } camera.setDisplayOrientation(result); } } -- cgit v1.1