diff options
author | Camera Software Integration <camswint@localhost> | 2016-01-05 17:41:22 -0800 |
---|---|---|
committer | sujit das <camswint@localhost> | 2016-01-08 13:36:51 +0530 |
commit | 67653312c11ece51fa633390fd7cfcabff9559bb (patch) | |
tree | 884fc7ea685571119d0cbd67d18fabc46aea8972 /src/com/android/camera/util | |
parent | dfd1abb2af1788d68f61ce0365b980e19100a284 (diff) | |
download | android_packages_apps_Snap-67653312c11ece51fa633390fd7cfcabff9559bb.tar.gz android_packages_apps_Snap-67653312c11ece51fa633390fd7cfcabff9559bb.tar.bz2 android_packages_apps_Snap-67653312c11ece51fa633390fd7cfcabff9559bb.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/com/android/camera/util')
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 56 |
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 5fb00ca65..812220c1a 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -1131,35 +1131,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; } |