我正在使用CameraX来开发我的安卓应用程序,在其中当我以横屏模式或竖屏模式拍照时,所拍摄的图像会被翻转。我知道前置摄像头也是这样工作的。但是,如果我想以与拍摄时相同的方式保存图片,该怎么办呢?
下面是我使用的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)
}
请帮忙指导应该如何更改设置以正确捕获图像。 注意:相机面向前方,且处于横屏模式。
img.recycle();
时要小心。因为我在项目中进一步使用了src位图,所以它给我带来了一个非常奇怪和难以追踪的错误。 我得到的错误是:2021-04-28 10:47:30.073 13573-15598/APPNAME A/libc: Fatal signal 11 (SIGSEGV),code 1 (SEGV_MAPERR),fault addr 0x70 in tid 15598 (pool-7-thread-1),pid 13573 (ev.APPNAME )
- Raul Lucaciu