summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2010-12-16 19:56:26 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-12-16 19:56:26 -0800
commit7f01a4587e989b2265c9e24d9c8cb3d1a47506f9 (patch)
treedcd67bbdbd229c9dc59e3b5ce07aead09c7a460e /src/com/android/camera
parent8dab44358e2f93b159f868e82cfac37a17269ba5 (diff)
parent0fad45d0d64569098f4daf34ff7e5ae785601304 (diff)
downloadLegacyCamera-7f01a4587e989b2265c9e24d9c8cb3d1a47506f9.zip
LegacyCamera-7f01a4587e989b2265c9e24d9c8cb3d1a47506f9.tar.gz
LegacyCamera-7f01a4587e989b2265c9e24d9c8cb3d1a47506f9.tar.bz2
Merge "Choose the preview size that has the same aspect ratio as picture size."
Diffstat (limited to 'src/com/android/camera')
-rw-r--r--src/com/android/camera/Camera.java17
-rw-r--r--src/com/android/camera/Util.java8
2 files changed, 13 insertions, 12 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index 2905ba0..4adff4d 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -1879,17 +1879,16 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
List<Size> sizes = mParameters.getSupportedPreviewSizes();
Size optimalSize = Util.getOptimalPreviewSize(this,
sizes, (double) size.width / size.height);
- if (optimalSize != null) {
- Size original = mParameters.getPreviewSize();
- if (!original.equals(optimalSize)) {
- mParameters.setPreviewSize(optimalSize.width, optimalSize.height);
+ Size original = mParameters.getPreviewSize();
+ if (!original.equals(optimalSize)) {
+ mParameters.setPreviewSize(optimalSize.width, optimalSize.height);
- // Zoom related settings will be changed for different preview
- // sizes, so set and read the parameters to get lastest values
- mCameraDevice.setParameters(mParameters);
- mParameters = mCameraDevice.getParameters();
- }
+ // Zoom related settings will be changed for different preview
+ // sizes, so set and read the parameters to get lastest values
+ mCameraDevice.setParameters(mParameters);
+ mParameters = mCameraDevice.getParameters();
}
+ Log.v(TAG, "Preview size is " + optimalSize.width + "x" + optimalSize.height);
// Since change scene mode may change supported values,
// Set scene mode first,
diff --git a/src/com/android/camera/Util.java b/src/com/android/camera/Util.java
index 3e5dd77..f2350d0 100644
--- a/src/com/android/camera/Util.java
+++ b/src/com/android/camera/Util.java
@@ -337,7 +337,8 @@ public class Util {
public static Size getOptimalPreviewSize(Activity currentActivity,
List<Size> sizes, double targetRatio) {
- final double ASPECT_TOLERANCE = 0.05;
+ // 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;
@@ -367,9 +368,10 @@ public class Util {
}
}
- // Cannot find the one match the aspect ratio, ignore the requirement
+ // Cannot find the one match the aspect ratio. This should not happen.
+ // Ignore the requirement.
if (optimalSize == null) {
- Log.v(TAG, "No preview size match the aspect ratio");
+ Log.w(TAG, "No preview size match the aspect ratio");
minDiff = Double.MAX_VALUE;
for (Size size : sizes) {
if (Math.abs(size.height - targetHeight) < minDiff) {