diff options
author | Wu-cheng Li <wuchengli@google.com> | 2010-10-18 19:37:45 +0800 |
---|---|---|
committer | Wu-cheng Li <wuchengli@google.com> | 2010-10-19 14:55:43 +0800 |
commit | c1dd72054122befb49aa1ca11ffa589b00186f80 (patch) | |
tree | db8945475a8ee329a8fed38e80c50f9a02f0c517 /src/com/android/camera/Util.java | |
parent | a7c1c50e4b96717f1b915f25ed4423bdcc04cfe0 (diff) | |
download | packages_apps_LegacyCamera-c1dd72054122befb49aa1ca11ffa589b00186f80.tar.gz packages_apps_LegacyCamera-c1dd72054122befb49aa1ca11ffa589b00186f80.tar.bz2 packages_apps_LegacyCamera-c1dd72054122befb49aa1ca11ffa589b00186f80.zip |
Fix wrong usage of setRotation and setOrientation.
bug:3105659
Change-Id: Ie2c1559cc03ece66705c1d766bea0e736f2684bc
Diffstat (limited to 'src/com/android/camera/Util.java')
-rw-r--r-- | src/com/android/camera/Util.java | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java index adf91529..d5cd7681 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); } } |