diff options
author | andralex8 <andralex8@gmail.com> | 2017-05-28 16:56:39 +0200 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2018-01-26 01:07:50 +0100 |
commit | 1d737fe6463b30ad4108223d5e8a76fc4d723be4 (patch) | |
tree | 4887d1138b232a27589f3734a56e6b1edd527e98 /src/com/android/camera/WideAnglePanoramaModule.java | |
parent | 338926556da9322fa2d17054f8a9f11c0bd29e7f (diff) | |
download | android_packages_apps_Snap-1d737fe6463b30ad4108223d5e8a76fc4d723be4.tar.gz android_packages_apps_Snap-1d737fe6463b30ad4108223d5e8a76fc4d723be4.tar.bz2 android_packages_apps_Snap-1d737fe6463b30ad4108223d5e8a76fc4d723be4.zip |
Add orientation correction for landscape devices
Snap does not correctly handle devices with a landscape screen as rotation
is 0 when device is in landscape while Snap assume that 0 is portrait.
This lead to a rotated gui and a deformed preview.
This commit:
- Solve the gui rotation for Photo, Video and Panorama modules
- Solve the deformed preview for Photo and Video (Panorama preview was ok with gui fix)
- Solve the PhotoMenu rotation (all devices, it was also broken on portrait devices)
Change-Id: Ic0b95904da6e13946c7e46e2e571b26da498db02
Diffstat (limited to 'src/com/android/camera/WideAnglePanoramaModule.java')
-rw-r--r-- | src/com/android/camera/WideAnglePanoramaModule.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java index 4e0da9fbe..ebf640f73 100644 --- a/src/com/android/camera/WideAnglePanoramaModule.java +++ b/src/com/android/camera/WideAnglePanoramaModule.java @@ -133,6 +133,7 @@ public class WideAnglePanoramaModule // respectively. private int mDeviceOrientation; private int mDeviceOrientationAtCapture; + private int mOrientationOffset; private int mCameraOrientation; private int mOrientationCompensation; private boolean mOrientationLocked; @@ -197,6 +198,7 @@ public class WideAnglePanoramaModule // the camera then point the camera to floor or sky, we still have // the correct orientation. if (orientation == ORIENTATION_UNKNOWN) return; + orientation = (orientation - mOrientationOffset + 360) % 360; int oldOrientation = mDeviceOrientation; mDeviceOrientation = CameraUtil.roundOrientation(orientation, mDeviceOrientation); // When the screen is unlocked, display rotation may change. Always @@ -230,6 +232,7 @@ public class WideAnglePanoramaModule public void init(CameraActivity activity, View parent) { mActivity = activity; mRootView = parent; + mOrientationOffset = CameraUtil.isDefaultToPortrait(mActivity) ? 0 : 90; mOrientationManager = new OrientationManager(activity); mCaptureState = CAPTURE_STATE_VIEWFINDER; @@ -728,9 +731,9 @@ public class WideAnglePanoramaModule if (mUsingFrontCamera) { // mCameraOrientation is negative with respect to the front facing camera. // See document of android.hardware.Camera.Parameters.setRotation. - orientation = (mDeviceOrientationAtCapture - mCameraOrientation - 360) % 360; + orientation = (mDeviceOrientationAtCapture - mCameraOrientation - mOrientationOffset + 360) % 360; } else { - orientation = (mDeviceOrientationAtCapture + mCameraOrientation) % 360; + orientation = (mDeviceOrientationAtCapture + mCameraOrientation + mOrientationOffset) % 360; } return orientation; } |