From e5d80904c60a105a034d0b0df3304ed6f001001a Mon Sep 17 00:00:00 2001 From: Camera Software Integration Date: Tue, 5 Jan 2016 17:41:22 -0800 Subject: 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 --- src/com/android/camera/util/CameraUtil.java | 56 +++++++++++++++-------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'src/com/android/camera') 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; } -- cgit v1.2.3