summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/camera/util')
-rw-r--r--src/com/android/camera/util/CameraUtil.java28
-rw-r--r--src/com/android/camera/util/PersistUtil.java31
2 files changed, 49 insertions, 10 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 28cb8e3b2..838f8d950 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -844,6 +844,34 @@ public class CameraUtil {
view.setVisibility(View.GONE);
}
+ public static Rect getFinalCropRect(Rect rect, float targetRatio) {
+ Rect finalRect = new Rect(rect);
+ float rectRatio = (float) rect.width()/(float) rect.height();
+
+ // if ratios are different, adjust crop rect to fit ratio
+ // if ratios are same, no need to adjust crop
+ Log.d(TAG, "getFinalCropRect - rect: " + rect.toString());
+ Log.d(TAG, "getFinalCropRect - ratios: " + rectRatio + ", " + targetRatio);
+ if(rectRatio > targetRatio) {
+ // ratio indicates need for horizontal crop
+ // add .5 to round up if necessary
+ int newWidth = (int)(((float)rect.height() * targetRatio) + .5f);
+ int newXoffset = (rect.width() - newWidth)/2 + rect.left;
+ finalRect.left = newXoffset;
+ finalRect.right = newXoffset + newWidth;
+ } else if(rectRatio < targetRatio) {
+ // ratio indicates need for vertical crop
+ // add .5 to round up if necessary
+ int newHeight = (int)(((float)rect.width() / targetRatio) + .5f);
+ int newYoffset = (rect.height() - newHeight)/2 + rect.top;
+ finalRect.top = newYoffset;
+ finalRect.bottom = newYoffset + newHeight;
+ }
+
+ Log.d(TAG, "getFinalCropRect - final rect: " + finalRect.toString());
+ return finalRect;
+ }
+
public static int getJpegRotation(int cameraId, int orientation) {
// See android.hardware.Camera.Parameters.setRotation for
// documentation.
diff --git a/src/com/android/camera/util/PersistUtil.java b/src/com/android/camera/util/PersistUtil.java
index bd623cf57..cce0e20d3 100644
--- a/src/com/android/camera/util/PersistUtil.java
+++ b/src/com/android/camera/util/PersistUtil.java
@@ -32,29 +32,40 @@ import android.os.SystemProperties;
public class PersistUtil {
- private static final String PERSIST_MEMORY_LIMIT = "persist.camera.perf.memlimit";
- private static final String PERSIST_SKIP_MEMORY_CHECK = "persist.camera.perf.skip_memck";
- private static final String PERSIST_LONGSHOT_SHOT_LIMIT = "persist.camera.longshot.shotnum";
- private static final String PERSIST_CAMERA_PREVIEW_SIZE = "persist.camera.preview.size";
- private static final String PERSIST_CAMERA_CAMERA2 = "persist.camera.camera2";
+ private static final int PERSIST_MEMORY_LIMIT =
+ SystemProperties.getInt("persist.camera.perf.memlimit", 60);
+ private static final boolean PERSIST_SKIP_MEMORY_CHECK =
+ SystemProperties.getBoolean("persist.camera.perf.skip_memck", false);
+ private static final int PERSIST_LONGSHOT_SHOT_LIMIT =
+ SystemProperties.getInt("persist.camera.longshot.shotnum", 50);
+ private static final int PERSIST_CAMERA_PREVIEW_SIZE =
+ SystemProperties.getInt("persist.camera.preview.size", 0);
+ private static final boolean PERSIST_CAMERA_CAMERA2 =
+ SystemProperties.getBoolean("persist.camera.camera2", false);
+ private static final boolean PERSIST_CAMERA_ZSL =
+ SystemProperties.getBoolean("persist.camera.zsl.disabled", false);
public static int getMemoryLimit() {
- return SystemProperties.getInt(PERSIST_MEMORY_LIMIT, 60);
+ return PERSIST_MEMORY_LIMIT;
}
public static boolean getSkipMemoryCheck() {
- return SystemProperties.getBoolean(PERSIST_SKIP_MEMORY_CHECK, false);
+ return PERSIST_SKIP_MEMORY_CHECK;
}
public static int getLongshotShotLimit() {
- return SystemProperties.getInt(PERSIST_LONGSHOT_SHOT_LIMIT, 20);
+ return PERSIST_LONGSHOT_SHOT_LIMIT;
}
public static int getCameraPreviewSize() {
- return SystemProperties.getInt(PERSIST_CAMERA_PREVIEW_SIZE, 0);
+ return PERSIST_CAMERA_PREVIEW_SIZE;
}
public static boolean getCamera2Mode() {
- return SystemProperties.getBoolean(PERSIST_CAMERA_CAMERA2, false);
+ return PERSIST_CAMERA_CAMERA2;
+ }
+
+ public static boolean getCameraZSLDisabled() {
+ return PERSIST_CAMERA_ZSL;
}
}