summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/WideAnglePanoramaModule.java
diff options
context:
space:
mode:
authorandralex8 <andralex8@gmail.com>2017-05-28 16:56:39 +0200
committerMichael Bestas <mkbestas@lineageos.org>2017-06-26 23:25:31 +0000
commit25a16bc1cd3c58c4120e5eaf2796f9d7a8f863e3 (patch)
treeda64a69e76fb1a5e3c1de48f3da57d46ec959b1a /src/com/android/camera/WideAnglePanoramaModule.java
parent0a068b647a0fce069ad7990009954940c05ad79f (diff)
downloadandroid_packages_apps_Snap-25a16bc1cd3c58c4120e5eaf2796f9d7a8f863e3.tar.gz
android_packages_apps_Snap-25a16bc1cd3c58c4120e5eaf2796f9d7a8f863e3.tar.bz2
android_packages_apps_Snap-25a16bc1cd3c58c4120e5eaf2796f9d7a8f863e3.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.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java
index 6068ef29b..4a84ed700 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;
@@ -720,9 +723,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;
}