diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2015-05-13 00:09:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-13 00:09:50 +0000 |
commit | 4143fbcfa88e6557f08d62325c62af6b8ec25b39 (patch) | |
tree | 2110ea30053408847fdc9ddd76d4e862712c2320 /core/java/android | |
parent | 8c6cd9088ebcb48db9d43c9340f77097a1c25b37 (diff) | |
parent | 607e4cb9ec709a0cbdb3d925a020c43aea270241 (diff) | |
download | frameworks_base-4143fbcfa88e6557f08d62325c62af6b8ec25b39.zip frameworks_base-4143fbcfa88e6557f08d62325c62af6b8ec25b39.tar.gz frameworks_base-4143fbcfa88e6557f08d62325c62af6b8ec25b39.tar.bz2 |
Merge "camera2: Fix crop selection in LEGACY." into mnc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/hardware/camera2/legacy/ParameterUtils.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/core/java/android/hardware/camera2/legacy/ParameterUtils.java b/core/java/android/hardware/camera2/legacy/ParameterUtils.java index 9e9a6fe..32bbc51 100644 --- a/core/java/android/hardware/camera2/legacy/ParameterUtils.java +++ b/core/java/android/hardware/camera2/legacy/ParameterUtils.java @@ -61,6 +61,8 @@ public class ParameterUtils { public static final Rect RECTANGLE_EMPTY = new Rect(/*left*/0, /*top*/0, /*right*/0, /*bottom*/0); + private static final double ASPECT_RATIO_TOLERANCE = 0.05f; + /** * Calculate effective/reported zoom data from a user-specified crop region. */ @@ -498,7 +500,10 @@ public class ParameterUtils { float aspectRatioPreview = previewSize.getWidth() * 1.0f / previewSize.getHeight(); float cropH, cropW; - if (aspectRatioPreview < aspectRatioArray) { + if (Math.abs(aspectRatioPreview - aspectRatioArray) < ASPECT_RATIO_TOLERANCE) { + cropH = activeArray.height(); + cropW = activeArray.width(); + } else if (aspectRatioPreview < aspectRatioArray) { // The new width must be smaller than the height, so scale the width by AR cropH = activeArray.height(); cropW = cropH * aspectRatioPreview; |