From ced60586c2bf376b46c0daedb0903098fa0a4dec Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Wed, 22 Nov 2017 11:12:31 +0100 Subject: [PATCH] Change the offset computation for front cameras (#112) --- .../java/com/otaliastudios/cameraview/CameraController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java index a5d80006..a7387fd7 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java @@ -406,8 +406,9 @@ abstract class CameraController implements */ protected final int computeSensorToViewOffset() { if (mFacing == Facing.FRONT) { - // or: (360 - ((mSensorOffset + mDisplayOffset) % 360)) % 360; - return ((mSensorOffset - mDisplayOffset) + 360 + 180) % 360; + // Here we had ((mSensorOffset - mDisplayOffset) + 360 + 180) % 360 + // And it seemed to give the same results for various combinations, but not for all (e.g. 0 - 270). + return (360 - ((mSensorOffset + mDisplayOffset) % 360)) % 360; } else { return (mSensorOffset - mDisplayOffset + 360) % 360; }