diff options
author | satyavaraprasad yerramsetti <satyav@codeaurora.org> | 2014-10-31 15:01:39 +0530 |
---|---|---|
committer | satyavaraprasad yerramsetti <satyav@codeaurora.org> | 2014-10-31 17:38:34 +0530 |
commit | c2248d747619ddc2f2c6521e5c755961ed031767 (patch) | |
tree | dfb2dd35a0fb9a72e20e0fa593107690d1e3e0d2 /src/com/android/camera/util/CameraUtil.java | |
parent | 6c20d314ec43be447e9a2bfb17e96452d996a18b (diff) | |
download | android_packages_apps_Snap-c2248d747619ddc2f2c6521e5c755961ed031767.tar.gz android_packages_apps_Snap-c2248d747619ddc2f2c6521e5c755961ed031767.tar.bz2 android_packages_apps_Snap-c2248d747619ddc2f2c6521e5c755961ed031767.zip |
SnapdragonCamera: Add OptimalJpegThumbnailSize selction logic in APP.
- Set a jpegthumbnail size that is closest to the Picture height and has
the right aspect ratio.
- Earlier this logic was implemented in HAL but due to CTS2 testJpegExif
failure, moving this to APP
CRs-Fixed: 748114
Change-Id: Ia2c97bf8cec7198ee291e63c3be9bbe5fb18b3b7
Diffstat (limited to 'src/com/android/camera/util/CameraUtil.java')
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index cfddf957e..4cfc211bc 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -567,6 +567,38 @@ public class CameraUtil { return optimalSize; } + + // Returns the largest thumbnail size which matches the given aspect ratio. + public static Size getOptimalJpegThumbnailSize( + List<Size> sizes, double targetRatio) { + // Use a very small tolerance because we want an exact match. + final double ASPECT_TOLERANCE = 0.001; + if (sizes == null) return null; + + Size optimalSize = null; + + // Try to find a size matches aspect ratio and has the largest width + for (Size size : sizes) { + double ratio = (double) size.width / size.height; + if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; + if (optimalSize == null || size.width > optimalSize.width) { + optimalSize = size; + } + } + + // Cannot find one that matches the aspect ratio. This should not happen. + // Ignore the requirement. + if (optimalSize == null) { + Log.w(TAG, "No thumbnail size match the aspect ratio"); + for (Size size : sizes) { + if (optimalSize == null || size.width > optimalSize.width) { + optimalSize = size; + } + } + } + return optimalSize; + } + public static void dumpParameters(Parameters parameters) { String flattened = parameters.flatten(); StringTokenizer tokenizer = new StringTokenizer(flattened, ";"); |