diff options
author | Jack Yoo <jyoo@codeaurora.org> | 2016-10-25 13:55:10 -0700 |
---|---|---|
committer | Jack Yoo <jyoo@codeaurora.org> | 2016-11-09 09:41:48 -0800 |
commit | 9129e68c256c9381889d4f3a475961feba9eaaa2 (patch) | |
tree | b2a959259484d3186d86569f5b00592f9e6ea832 /src/com/android/camera/util | |
parent | 0c43eccb63dae31813b998a92e1d50b29a41be04 (diff) | |
download | android_packages_apps_Snap-9129e68c256c9381889d4f3a475961feba9eaaa2.tar.gz android_packages_apps_Snap-9129e68c256c9381889d4f3a475961feba9eaaa2.tar.bz2 android_packages_apps_Snap-9129e68c256c9381889d4f3a475961feba9eaaa2.zip |
SnapdragonCamera: Continuous shot to YUV
Change continuous shot to YUV with ZSL
Change-Id: If69d58456a17fa4181cf58f9660c0c6d033c4938
CRs-Fixed: 1083651
Diffstat (limited to 'src/com/android/camera/util')
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index 1cdfd285a..1dc5e558b 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -842,6 +842,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. |