diff options
author | likaid <likaid@codeaurora.org> | 2015-06-23 09:55:22 +0800 |
---|---|---|
committer | gfxgitp4 <gfxgitp4@localhost> | 2015-07-02 22:51:53 -0600 |
commit | 06d0fc3bc1d55a17648cfb26ee8e75d0d647fa64 (patch) | |
tree | 4f112754f05257eda9f56ac9fd2fceb60e4e5935 /src/com/android/camera/util | |
parent | 1496191cf7c18bf2cc7997de06a154bf46a8dad1 (diff) | |
download | android_packages_apps_Snap-06d0fc3bc1d55a17648cfb26ee8e75d0d647fa64.tar.gz android_packages_apps_Snap-06d0fc3bc1d55a17648cfb26ee8e75d0d647fa64.tar.bz2 android_packages_apps_Snap-06d0fc3bc1d55a17648cfb26ee8e75d0d647fa64.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
Diffstat (limited to 'src/com/android/camera/util')
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 21 |
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; } } |