summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlikaid <likaid@codeaurora.org>2015-06-23 09:55:22 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2015-07-02 21:42:21 -0700
commit65ef775414a7cb604cf7f5a417152a67704669c7 (patch)
tree8fde4d4b3842eecb9d2586c5ab999785e1ec43d4
parent3c0375c4d3d0acd532801ca42caf29297390966a (diff)
downloadandroid_packages_apps_Snap-65ef775414a7cb604cf7f5a417152a67704669c7.tar.gz
android_packages_apps_Snap-65ef775414a7cb604cf7f5a417152a67704669c7.tar.bz2
android_packages_apps_Snap-65ef775414a7cb604cf7f5a417152a67704669c7.zip
SnapdragonCamera: Add new preview aspect ratio for 3:2 pictures
When the captured picture was 3:2 aspect ratio (e.g 720x480), the image was deformed on camera preview, since it was treated as 4:3 ratio on preview layout. Change-Id: I4c170f53c9dfdc7e90ee736631be02cef1f574c2 CRs-Fixed: 857138
-rw-r--r--src/com/android/camera/util/CameraUtil.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 51c91cfe5..7201a7f8c 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -124,6 +124,7 @@ public class CameraUtil {
public static final int RATIO_UNKNOWN = 0;
public static final int RATIO_16_9 = 1;
public static final int RATIO_4_3 = 2;
+ public static final int RATIO_3_2 = 3;
public static boolean isSupported(String value, List<String> supported) {
return supported == null ? false : supported.indexOf(value) >= 0;
@@ -1089,6 +1090,8 @@ public class CameraUtil {
return RATIO_4_3;
} else if (ratio > 1.77f && ratio < 1.78f) {
return RATIO_16_9;
+ } else if (ratio > 1.49f && ratio < 1.51f) {
+ return RATIO_3_2;
} else {
return RATIO_UNKNOWN;
}
@@ -1109,11 +1112,23 @@ public class CameraUtil {
diffFrom_16_9 = 1 / diffFrom_16_9;
}
- if (diffFrom_4_3 < diffFrom_16_9) {
- return RATIO_4_3;
+ float diffFrom_3_2 = ((float) 3 / 2) / ratio;
+ if (diffFrom_3_2 < 1) {
+ diffFrom_3_2 = 1 / diffFrom_3_2;
+ }
+ int retRatio = RATIO_UNKNOWN;
+ float minDiffRatio = diffFrom_3_2;
+ if (diffFrom_3_2 < diffFrom_4_3) {
+ retRatio = RATIO_3_2;
+ minDiffRatio = diffFrom_3_2;
} else {
- return RATIO_16_9;
+ retRatio = RATIO_4_3;
+ minDiffRatio = diffFrom_4_3;
+ }
+ if (minDiffRatio > diffFrom_16_9) {
+ retRatio = RATIO_16_9;
}
+ return retRatio;
}
}