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 | |
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')
-rw-r--r-- | src/com/android/camera/Camera.java | 14 | ||||
-rw-r--r-- | src/com/android/camera/Util.java | 18 |
2 files changed, 20 insertions, 12 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index c9c73948..99951c3f 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -776,16 +776,16 @@ public class Camera extends NoSearchActivity implements View.OnClickListener, private void capture() { mCaptureOnlyData = null; - // Set JPEG rotation to match the orientation of what users see. The - // rotation is relative to the orientation of the camera. The value - // from OrientationEventListener is relative to the natural - // orientation of the device. CameraInfo.mOrientation is the angle - // between camera orientation and natural device orientation. The - // sum of the two is the value for setRotation. + // See android.hardware.Camera.Parameters.setRotation for + // documentation. int rotation = 0; if (mOrientation != OrientationEventListener.ORIENTATION_UNKNOWN) { CameraInfo info = CameraHolder.instance().getCameraInfo()[mCameraId]; - rotation = (mOrientation + info.orientation) % 360; + if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { + rotation = (info.orientation - mOrientation + 360) % 360; + } else { // back-facing camera + rotation = (info.orientation + mOrientation) % 360; + } } mParameters.setRotation(rotation); 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); } } |