From 4f554a51846d8994873f44193e66d39c59d26678 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Fri, 4 Aug 2017 11:41:27 +0200 Subject: [PATCH] Fix exif orientation for facing camera --- .../api16/com/flurgle/camerakit/Camera1.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java index 7a1deb75..86fd01ef 100644 --- a/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java +++ b/camerakit/src/main/api16/com/flurgle/camerakit/Camera1.java @@ -368,16 +368,15 @@ class Camera1 extends CameraImpl { // Set boolean to wait for image callback mIsCapturingImage = true; + final int exifRotation = computeExifRotation(); + final boolean exifFlip = computeExifFlip(); + final int sensorToDisplay = computeSensorToDisplayOffset(); synchronized (mLock) { Camera.Parameters parameters = mCamera.getParameters(); - int rotation = computeExifRotation(); - Log.e(TAG, "Setting exif rotation to "+rotation); - parameters.setRotation(rotation); + Log.e(TAG, "Setting exif rotation to "+exifRotation); + parameters.setRotation(exifRotation); mCamera.setParameters(parameters); } - final int exifRotation = computeExifRotation(); - final boolean exifFlip = computeExifFlip(); - final int sensorToDisplay = computeSensorToDisplayOffset(); // Is the final picture (decoded respecting EXIF) consistent with CameraView orientation? // We must consider exifOrientation to bring back the picture in the sensor world. // Then use sensorToDisplay to move to the display world, where CameraView lives. @@ -479,7 +478,11 @@ class Camera1 extends CameraImpl { * This ignores flipping for facing camera. */ private int computeExifRotation() { - return (mDeviceOrientation + mSensorOffset) % 360; + if (mFacing == CameraKit.Constants.FACING_FRONT) { + return (mSensorOffset - mDeviceOrientation + 360) % 360; + } else { + return (mSensorOffset + mDeviceOrientation) % 360; + } }