-
-
Save deepak140596/0d370a3deae87f0c23c1eecf1dec5e17 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private fun updateTransform() { | |
val matrix = Matrix() | |
// Compute the center of the view finder | |
val centerX = viewFinder.width / 2f | |
val centerY = viewFinder.height / 2f | |
// Correct preview output to account for display rotation | |
val rotationDegrees = when(viewFinder.display.rotation) { | |
Surface.ROTATION_0 -> 0 | |
Surface.ROTATION_90 -> 90 | |
Surface.ROTATION_180 -> 180 | |
Surface.ROTATION_270 -> 270 | |
else -> return | |
} | |
matrix.postRotate(-rotationDegrees.toFloat(), centerX, centerY) | |
// Finally, apply transformations to our TextureView | |
viewFinder.setTransform(matrix) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment