summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCamera Software Integration <camswint@localhost>2016-01-05 17:41:22 -0800
committerMichael Bestas <mikeioannina@cyanogenmod.org>2016-02-16 15:44:54 +0200
commite5d80904c60a105a034d0b0df3304ed6f001001a (patch)
tree34b3e299827a5ecfa6b284f57ea23667eb765328 /src
parenta05f9ce2cfa6dc7f94d38580d0ce7092b5507947 (diff)
downloadandroid_packages_apps_Snap-e5d80904c60a105a034d0b0df3304ed6f001001a.tar.gz
android_packages_apps_Snap-e5d80904c60a105a034d0b0df3304ed6f001001a.tar.bz2
android_packages_apps_Snap-e5d80904c60a105a034d0b0df3304ed6f001001a.zip
SnapdragonCamera: fix the incorrect aspect ratio calculation
For square size picture, the function that calculates the closest aspect ratio, forced it to use 4:3 ratio and caused the preview stretched from 1:1 to 4:3. Fix the issue by skipping the logic that forces it to 4:3 aspect ratio when the picture size is square. Change-Id: Ia7d8250152ce37f4444f7db7c752eeb8489d9a2f CRs-Fixed: 955824
Diffstat (limited to 'src')
-rw-r--r--src/com/android/camera/util/CameraUtil.java56
1 files changed, 30 insertions, 26 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 96ee0d927..50fd13933 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -1153,35 +1153,39 @@ public class CameraUtil {
}
public static int determinCloseRatio(float ratio) {
- if (ratio < 1) {
- ratio = 1 / ratio;
- }
+ int retRatio = RATIO_UNKNOWN;
- float diffFrom_4_3 = ((float) 4 / 3) / ratio;
- if (diffFrom_4_3 < 1) {
- diffFrom_4_3 = 1 / diffFrom_4_3;
- }
+ if (ratio != 1.0) {
- float diffFrom_16_9 = ((float) 16 / 9) / ratio;
- if (diffFrom_16_9 < 1) {
- diffFrom_16_9 = 1 / diffFrom_16_9;
- }
+ if (ratio < 1) {
+ ratio = 1 / ratio;
+ }
- 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 {
- retRatio = RATIO_4_3;
- minDiffRatio = diffFrom_4_3;
- }
- if (minDiffRatio > diffFrom_16_9) {
- retRatio = RATIO_16_9;
+ float diffFrom_4_3 = ((float) 4 / 3) / ratio;
+ if (diffFrom_4_3 < 1) {
+ diffFrom_4_3 = 1 / diffFrom_4_3;
+ }
+
+ float diffFrom_16_9 = ((float) 16 / 9) / ratio;
+ if (diffFrom_16_9 < 1) {
+ diffFrom_16_9 = 1 / diffFrom_16_9;
+ }
+
+ float diffFrom_3_2 = ((float) 3 / 2) / ratio;
+ if (diffFrom_3_2 < 1) {
+ diffFrom_3_2 = 1 / diffFrom_3_2;
+ }
+ float minDiffRatio = diffFrom_3_2;
+ if (diffFrom_3_2 < diffFrom_4_3) {
+ retRatio = RATIO_3_2;
+ minDiffRatio = diffFrom_3_2;
+ } else {
+ retRatio = RATIO_4_3;
+ minDiffRatio = diffFrom_4_3;
+ }
+ if (minDiffRatio > diffFrom_16_9) {
+ retRatio = RATIO_16_9;
+ }
}
return retRatio;
}