diff options
| author | Kerong Sui <ksui@codeaurora.org> | 2013-08-07 17:12:02 +0800 |
|---|---|---|
| committer | Steve Kondik <shade@chemlab.org> | 2013-10-18 15:54:49 -0700 |
| commit | bd18276c284e8b041a0130dc1ac8998e10ddeb9d (patch) | |
| tree | 387a610d60a61f4056457524e5c422e36a8bca7a | |
| parent | 39aa292b2adc0924c7b36a1798c9ae9bea333f25 (diff) | |
| download | android_packages_apps_Gallery2-bd18276c284e8b041a0130dc1ac8998e10ddeb9d.tar.gz android_packages_apps_Gallery2-bd18276c284e8b041a0130dc1ac8998e10ddeb9d.tar.bz2 android_packages_apps_Gallery2-bd18276c284e8b041a0130dc1ac8998e10ddeb9d.zip | |
Camera: Fix panorama preview/snapshot rotation issue
Remove earlier hardcode and use unified solution to solve Panorama
preview and snapshot rotation issue by using sensor mount angle and
angle compensation in panorama postprocessing.
Change-Id: If68c6500c41c7cb3c461352826f1fec45db0a5b0
| -rw-r--r-- | src/com/android/camera/PanoramaModule.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/com/android/camera/PanoramaModule.java b/src/com/android/camera/PanoramaModule.java index 574b2763d..31b5a7f72 100644 --- a/src/com/android/camera/PanoramaModule.java +++ b/src/com/android/camera/PanoramaModule.java @@ -163,6 +163,7 @@ public class PanoramaModule implements CameraModule, private int mDeviceOrientation; private int mDeviceOrientationAtCapture; private int mCameraOrientation; + private int mPanoAngle; private int mOrientationCompensation; private RotateDialogController mRotateDialog; @@ -652,7 +653,9 @@ public class PanoramaModule implements CameraModule, (Math.abs(mProgressAngle[0]) > Math.abs(mProgressAngle[1])) ? (int) mProgressAngle[0] : (int) mProgressAngle[1]; - mPanoProgressBar.setProgress((angleInMajorDirection)); + //need to flip the direction if mPanoAngle is larger than 180 + mPanoProgressBar.setProgress(mPanoAngle >= 180 ? + (0 - angleInMajorDirection) : angleInMajorDirection); } private void setViews(Resources appRes) { @@ -784,17 +787,12 @@ public class PanoramaModule implements CameraModule, // device orientation at capture and the camera orientation respective to // the natural orientation of the device. int orientation; - int cameraOrientation = mCameraOrientation; - if(mDeviceOrientationAtCapture == 270 || mDeviceOrientationAtCapture == 90) { - if(mCameraOrientation == 0) - cameraOrientation = 180; - } if (mUsingFrontCamera) { // mCameraOrientation is negative with respect to the front facing camera. // See document of android.hardware.Camera.Parameters.setRotation. - orientation = (mDeviceOrientationAtCapture - cameraOrientation + 360) % 360; + orientation = (mDeviceOrientationAtCapture - mCameraOrientation - mPanoAngle + 360) % 360; } else { - orientation = (mDeviceOrientationAtCapture + cameraOrientation) % 360; + orientation = (mDeviceOrientationAtCapture + mCameraOrientation - mPanoAngle) % 360; } return orientation; } @@ -1163,10 +1161,12 @@ public class PanoramaModule implements CameraModule, // Set the display orientation to 0, so that the underlying mosaic // library can always get undistorted mPreviewWidth x mPreviewHeight // image data from SurfaceTexture. - if (mCameraOrientation == 0) - mCameraDevice.setDisplayOrientation(270); - else - mCameraDevice.setDisplayOrientation(0); + + // as Panoroma will add 90 degree rotation compensation during + // postprocessing, we need to consider both camera mount angle and + // this compensation angle + mPanoAngle = (mCameraOrientation - 90 + 360) % 360; + mCameraDevice.setDisplayOrientation(mPanoAngle); if (mCameraTexture != null) mCameraTexture.setOnFrameAvailableListener(this); mCameraDevice.setPreviewTextureAsync(mCameraTexture); |
