我正在使用 CameraX 开发我的 android 应用程序,其中当我在横向模式或纵向模式下拍摄照片时,捕获和保存的图像是镜像。
我知道前置摄像头的工作方式相同。但是,如果我想以与拍摄照片相同的方式保存照片,该怎么办?
这是buildUseCase()我正在使用的代码:
private fun buildUseCases() {
val screenAspectRatio = Rational(width, height)
val screenTargetRotation = display.rotation
//Preview
val previewConfig = PreviewConfig.Builder().apply {
setTargetAspectRatio(screenAspectRatio)
setTargetRotation(screenTargetRotation)
setLensFacing(lensFacing)
}.build()
preview = AutoFitPreviewBuilder.build(previewConfig, this)
//End - Preview
// Set up the capture use case to allow users to take photos
val imageCaptureConfig = ImageCaptureConfig.Builder().apply {
setTargetAspectRatio(screenAspectRatio)
setTargetRotation(screenTargetRotation)
setLensFacing(lensFacing)
setCaptureMode(ImageCapture.CaptureMode.MAX_QUALITY)
}.build()
imageCapture = ImageCapture(imageCaptureConfig)
}
Run Code Online (Sandbox Code Playgroud)
请帮助我进行更改以获取正确的图像。
注意:相机面向前方且处于横向模式。