diff options
author | Sascha Haeberling <haeberling@google.com> | 2014-02-14 11:06:03 +0100 |
---|---|---|
committer | Sascha Haeberling <haeberling@google.com> | 2014-02-21 07:50:47 -0800 |
commit | a7cbfc04d888624858271facdbf68797c54df8b6 (patch) | |
tree | 139f0fec073118bff1a7c8b42b98732441debb11 /src/com/android/camera/util/CameraUtil.java | |
parent | eb3f62f20df0a97d25d2390904631caf32a12d54 (diff) | |
download | android_packages_apps_Camera2-a7cbfc04d888624858271facdbf68797c54df8b6.tar.gz android_packages_apps_Camera2-a7cbfc04d888624858271facdbf68797c54df8b6.tar.bz2 android_packages_apps_Camera2-a7cbfc04d888624858271facdbf68797c54df8b6.zip |
To support Refocus orientation refactoring.
Bug: 13007150
Bug: 12996493
Change-Id: I360d0d0fcf8090d96277cd708bd8d0eb4e188b00
Diffstat (limited to 'src/com/android/camera/util/CameraUtil.java')
-rw-r--r-- | src/com/android/camera/util/CameraUtil.java | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java index 12075195a..242deb586 100644 --- a/src/com/android/camera/util/CameraUtil.java +++ b/src/com/android/camera/util/CameraUtil.java @@ -769,20 +769,19 @@ public class CameraUtil { view.setVisibility(View.GONE); } - public static int getJpegRotation(CameraActivity activity, int cameraId, int orientation) { - // See android.hardware.Camera.Parameters.setRotation for - // documentation. - int rotation = 0; - if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) { - CameraInfo info = activity.getCameraProvider().getCameraInfo()[cameraId]; - if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { - rotation = (info.orientation - orientation + 360) % 360; - } else { // back-facing camera - rotation = (info.orientation + orientation) % 360; - } - } - return rotation; - } + public static int getJpegRotation(CameraInfo info, int orientation) { + // See android.hardware.Camera.Parameters.setRotation for + // documentation. + int rotation = 0; + if (orientation != OrientationEventListener.ORIENTATION_UNKNOWN) { + if (info.facing == CameraInfo.CAMERA_FACING_FRONT) { + rotation = (info.orientation - orientation + 360) % 360; + } else { // back-facing camera + rotation = (info.orientation + orientation) % 360; + } + } + return rotation; + } /** * Down-samples a jpeg byte array. @@ -946,9 +945,9 @@ public class CameraUtil { */ public static int addPixel(int pixel, int newPixel, float weight) { // TODO: scale weight to [0, 1024] to avoid casting to float and back to int. - int r = ((pixel & 0x00ff0000) + (int) (((float) (newPixel & 0x00ff0000)) * weight)) & 0x00ff0000; - int g = ((pixel & 0x0000ff00) + (int) (((float) (newPixel & 0x0000ff00)) * weight)) & 0x0000ff00; - int b = ((pixel & 0x000000ff) + (int) (((float) (newPixel & 0x000000ff)) * weight)) & 0x000000ff; + int r = ((pixel & 0x00ff0000) + (int) ((newPixel & 0x00ff0000) * weight)) & 0x00ff0000; + int g = ((pixel & 0x0000ff00) + (int) ((newPixel & 0x0000ff00) * weight)) & 0x0000ff00; + int b = ((pixel & 0x000000ff) + (int) ((newPixel & 0x000000ff) * weight)) & 0x000000ff; return 0xff000000 | r | g | b; } |