mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-28 09:07:53 +01:00
fix #230, properly handle images captured with the front camera
This commit is contained in:
parent
b793026bbb
commit
715fc4f79a
@ -38,9 +38,8 @@ const val STATE_STARTING_RECORDING = 6
|
||||
const val STATE_STOPING_RECORDING = 7
|
||||
const val STATE_RECORDING = 8
|
||||
|
||||
fun compensateDeviceRotation(orientation: Int, isUsingFrontCamera: Boolean) = when {
|
||||
orientation == ORIENT_LANDSCAPE_LEFT -> 270
|
||||
orientation == ORIENT_LANDSCAPE_RIGHT -> 90
|
||||
isUsingFrontCamera -> 180
|
||||
fun compensateDeviceRotation(orientation: Int) = when (orientation) {
|
||||
ORIENT_LANDSCAPE_LEFT -> 270
|
||||
ORIENT_LANDSCAPE_RIGHT -> 90
|
||||
else -> 0
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOr
|
||||
|
||||
val imageRot = orient.degreesFromOrientation()
|
||||
|
||||
val deviceRot = compensateDeviceRotation(deviceOrientation, isUsingFrontCamera)
|
||||
val deviceRot = compensateDeviceRotation(deviceOrientation)
|
||||
var image = BitmapFactory.decodeByteArray(data, 0, data.size)
|
||||
val totalRotation = (imageRot + deviceRot + previewRotation) % 360
|
||||
|
||||
|
@ -568,7 +568,7 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
||||
|
||||
mCameraState = STATE_PICTURE_TAKEN
|
||||
mRotationAtCapture = mActivity.mLastHandledOrientation
|
||||
val jpegOrientation = (mSensorOrientation + compensateDeviceRotation(mRotationAtCapture, mUseFrontCamera)) % 360
|
||||
val jpegOrientation = (mSensorOrientation + compensateDeviceRotation(mRotationAtCapture)) % 360
|
||||
val captureBuilder = mCameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply {
|
||||
addTarget(mImageReader!!.surface)
|
||||
setFlashAndExposure(this)
|
||||
|
Loading…
x
Reference in New Issue
Block a user