summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2010-10-19 11:18:23 -0700
committerJean-Baptiste Queru <jbq@google.com>2010-10-19 11:18:23 -0700
commit9a2b75b19b46ad5a66edf9a1c97f8da281c3dfdc (patch)
treec420795b10c4909a86a4212db0477c8cc5b8b2b0 /src
parentc4a762222cf20beee749a448be2bdf4765d06e54 (diff)
parent559a415158aa0b2efde072d29cfec1b82634fd2e (diff)
downloadLegacyCamera-9a2b75b19b46ad5a66edf9a1c97f8da281c3dfdc.zip
LegacyCamera-9a2b75b19b46ad5a66edf9a1c97f8da281c3dfdc.tar.gz
LegacyCamera-9a2b75b19b46ad5a66edf9a1c97f8da281c3dfdc.tar.bz2
Merge 559a4151 from gingerbread-plus-aosp
Change-Id: I8ec4aa5210cb5104bedb7d5ed6f823f44517b203
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/Camera.java14
-rw-r--r--src/com/android/camera/Util.java18
2 files changed, 20 insertions, 12 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index ebffe30..b626079 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -903,16 +903,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 2bff219..71d0c21 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -24,6 +24,7 @@ import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
+import android.hardware.Camera;
import android.hardware.Camera.Size;
import android.util.Log;
import android.view.Display;
@@ -295,12 +296,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);
}