From 8ae53e4f2f076025559029e0ba03a31710186ffb Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 11 Jun 2018 14:10:59 +0200 Subject: [PATCH] do not rotate the preview at front camera, always use sensor orientation --- .../camera/views/PreviewCameraTwo.kt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt index 104d1d51..709fca6a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/views/PreviewCameraTwo.kt @@ -275,20 +275,11 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie val buffer = reader.acquireNextImage().planes.first().buffer val bytes = ByteArray(buffer.remaining()) buffer.get(bytes) - PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, getJPEGOrientation(), mUseFrontCamera).execute(bytes) + PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, mSensorOrientation, mUseFrontCamera).execute(bytes) } catch (e: Exception) { } } - private fun getJPEGOrientation(): Int { - var orientation = mSensorOrientation - if (mUseFrontCamera) { - orientation += 180 - } - - return orientation % 360 - } - private fun getCurrentResolution(): MySize { val configMap = getCameraCharacteristics().get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP) val resIndex = if (mUseFrontCamera) { @@ -562,7 +553,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie addTarget(mImageReader!!.surface) setFlashAndExposure(this) set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE) - set(CaptureRequest.JPEG_ORIENTATION, getJPEGOrientation()) + set(CaptureRequest.JPEG_ORIENTATION, mSensorOrientation) set(CaptureRequest.SCALER_CROP_REGION, mZoomRect) set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE) }