fix #172, set SCALER_CROP_REGION at image capturing only if the user zoomed

This commit is contained in:
tibbi 2018-06-18 21:04:01 +02:00
parent 29fc0add5c
commit 7afa969505
1 changed files with 7 additions and 3 deletions

View File

@ -109,7 +109,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
private val mPreviewToCameraMatrix = Matrix()
private val mCameraOpenCloseLock = Semaphore(1)
private val mMediaActionSound = MediaActionSound()
private var mZoomRect = Rect()
private var mZoomRect: Rect? = null
constructor(context: Context) : super(context)
@ -557,8 +557,10 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
setFlashAndExposure(this)
set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)
set(CaptureRequest.JPEG_ORIENTATION, mSensorOrientation)
set(CaptureRequest.SCALER_CROP_REGION, mZoomRect)
set(CaptureRequest.CONTROL_CAPTURE_INTENT, CaptureRequest.CONTROL_CAPTURE_INTENT_STILL_CAPTURE)
if (mZoomRect != null) {
set(CaptureRequest.SCALER_CROP_REGION, mZoomRect)
}
}
val captureCallback = object : CameraCaptureSession.CaptureCallback() {
@ -706,8 +708,10 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
Handler().postDelayed({
if (mLastFocusX != 0f && mLastFocusY != 0f) {
if (mCaptureSession != null) {
focusArea(mLastFocusX, mLastFocusY, false)
}
}
}, 200L)
} catch (e: Exception) {
}