summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/Util.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/Util.java')
-rw-r--r--src/com/android/camera/Util.java18
1 files changed, 13 insertions, 5 deletions
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);
}