summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/Util.java
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-09-10 12:48:00 -0700
committerWu-cheng Li <wuchengli@google.com>2010-09-15 09:21:49 -0700
commit4aaa2130af7241f128ee561cafd17a4fb560b92c (patch)
tree0d92d61f352c0605a2fdaa63c909e4f2edd3a55d /src/com/android/camera/Util.java
parent8eaa6919f0d5c10c95c99f2f937d57ea5c4a5bba (diff)
downloadLegacyCamera-4aaa2130af7241f128ee561cafd17a4fb560b92c.zip
LegacyCamera-4aaa2130af7241f128ee561cafd17a4fb560b92c.tar.gz
LegacyCamera-4aaa2130af7241f128ee561cafd17a4fb560b92c.tar.bz2
Fix the wrong rotation on naturally landscape devices.
The orientation of on-screen icons and thumbnails are wrong on devices that are naturally landscape in their orientation. Display.getRotation should be used to compensate. Parameters.setRotation should also be compensated by camera's orientation. Change-Id: Ia0684fcd606252c49fa2d701ab07c73f7e29b70b
Diffstat (limited to 'src/com/android/camera/Util.java')
-rw-r--r--src/com/android/camera/Util.java23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index de99562..c5de1f8 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -280,21 +280,24 @@ public class Util {
return x;
}
- 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);
+ public static int getDisplayRotation(Activity activity) {
int rotation = activity.getWindowManager().getDefaultDisplay()
.getRotation();
- int degrees = 0;
switch (rotation) {
- case Surface.ROTATION_0: degrees = 0; break;
- case Surface.ROTATION_90: degrees = 90; break;
- case Surface.ROTATION_180: degrees = 180; break;
- case Surface.ROTATION_270: degrees = 270; break;
+ case Surface.ROTATION_0: return 0;
+ case Surface.ROTATION_90: return 90;
+ case Surface.ROTATION_180: return 180;
+ case Surface.ROTATION_270: return 270;
}
+ return 0;
+ }
+ 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 degrees = getDisplayRotation(activity);
int result = (info.mOrientation - degrees + 360) % 360;
camera.setDisplayOrientation(result);
}