Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrong orientation enum being send to ImageCapture #2683

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ class CameraSession(private val context: Context, private val callback: Callback
}

photoOutput.flashMode = flash.toFlashMode()
photoOutput.targetRotation = outputOrientation.toDegrees()
photoOutput.targetRotation = outputOrientation.toSurfaceRotation()

val photoFile = photoOutput.takePicture(context, enableShutterSound, metadataProvider, callback, CameraQueues.cameraExecutor)
val isMirrored = photoFile.metadata.isReversedHorizontal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mrousavy.camera.types

import android.view.Surface

enum class Orientation(override val unionValue: String) : JSUnionValue {
PORTRAIT("portrait"),
LANDSCAPE_RIGHT("landscape-right"),
Expand All @@ -14,6 +16,14 @@ enum class Orientation(override val unionValue: String) : JSUnionValue {
LANDSCAPE_RIGHT -> 270
}

fun toSurfaceRotation(): Int =
when (this) {
PORTRAIT -> Surface.ROTATION_0
LANDSCAPE_LEFT -> Surface.ROTATION_90
PORTRAIT_UPSIDE_DOWN -> Surface.ROTATION_180
LANDSCAPE_RIGHT -> Surface.ROTATION_270
}

companion object : JSUnionValue.Companion<Orientation> {
override fun fromUnionValue(unionValue: String?): Orientation =
when (unionValue) {
Expand Down
Loading