diff options
| author | Wu-cheng Li <wuchengli@google.com> | 2010-10-19 10:34:36 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2010-10-19 10:34:36 -0700 |
| commit | 559a415158aa0b2efde072d29cfec1b82634fd2e (patch) | |
| tree | db8945475a8ee329a8fed38e80c50f9a02f0c517 /src/com/android/camera/Util.java | |
| parent | 03f097a09297ac400d340b3c4ffff4a9312da4f0 (diff) | |
| parent | c1dd72054122befb49aa1ca11ffa589b00186f80 (diff) | |
| download | LegacyCamera-559a415158aa0b2efde072d29cfec1b82634fd2e.zip LegacyCamera-559a415158aa0b2efde072d29cfec1b82634fd2e.tar.gz LegacyCamera-559a415158aa0b2efde072d29cfec1b82634fd2e.tar.bz2 | |
am c1dd7205: Fix wrong usage of setRotation and setOrientation.
Merge commit 'c1dd72054122befb49aa1ca11ffa589b00186f80' into gingerbread-plus-aosp
* commit 'c1dd72054122befb49aa1ca11ffa589b00186f80':
Fix wrong usage of setRotation and setOrientation.
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 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); } } |
