update crop region permanently after zooming in/out

This commit is contained in:
tibbi 2018-06-01 22:58:50 +02:00
parent ac529cd07f
commit cc63675e3a
1 changed files with 3 additions and 3 deletions

View File

@ -182,7 +182,8 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
cropHeight -= cropHeight and 3 cropHeight -= cropHeight and 3
mZoomRect = Rect(cropWidth, cropHeight, sensorRect.width() - cropWidth, sensorRect.height() - cropHeight) mZoomRect = Rect(cropWidth, cropHeight, sensorRect.width() - cropWidth, sensorRect.height() - cropHeight)
mPreviewRequestBuilder!!.set(CaptureRequest.SCALER_CROP_REGION, mZoomRect) mPreviewRequestBuilder!!.set(CaptureRequest.SCALER_CROP_REGION, mZoomRect)
mCaptureSession!!.setRepeatingRequest(mPreviewRequestBuilder!!.build(), mCaptureCallback, mBackgroundHandler) mPreviewRequest = mPreviewRequestBuilder!!.build()
mCaptureSession!!.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler)
} }
mZoomFingerSpacing = currentFingerSpacing mZoomFingerSpacing = currentFingerSpacing
} }
@ -537,7 +538,6 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
mCameraState = STATE_WAITING_LOCK mCameraState = STATE_WAITING_LOCK
mPreviewRequestBuilder!!.apply { mPreviewRequestBuilder!!.apply {
set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START) set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START)
set(CaptureRequest.SCALER_CROP_REGION, mZoomRect)
mCaptureSession!!.capture(build(), mCaptureCallback, mBackgroundHandler) mCaptureSession!!.capture(build(), mCaptureCallback, mBackgroundHandler)
} }
} catch (e: CameraAccessException) { } catch (e: CameraAccessException) {
@ -546,12 +546,12 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
private fun unlockFocus() { private fun unlockFocus() {
try { try {
mCameraState = STATE_PREVIEW
mPreviewRequestBuilder!!.apply { mPreviewRequestBuilder!!.apply {
set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL) set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_CANCEL)
set(CaptureRequest.FLASH_MODE, getFlashlightMode(mFlashlightState)) set(CaptureRequest.FLASH_MODE, getFlashlightMode(mFlashlightState))
mCaptureSession!!.capture(build(), mCaptureCallback, mBackgroundHandler) mCaptureSession!!.capture(build(), mCaptureCallback, mBackgroundHandler)
} }
mCameraState = STATE_PREVIEW
mCaptureSession!!.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler) mCaptureSession!!.setRepeatingRequest(mPreviewRequest, mCaptureCallback, mBackgroundHandler)
} catch (e: CameraAccessException) { } catch (e: CameraAccessException) {
} }