mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-04-06 11:41:10 +02:00
couple updates related to capturing images with Camera2
This commit is contained in:
parent
78bdec9a9f
commit
15bf2ee193
@ -45,7 +45,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:4.6.3'
|
implementation 'com.simplemobiletools:commons:4.6.4'
|
||||||
|
|
||||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
||||||
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
|
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
|
||||||
|
@ -283,9 +283,11 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
|
|
||||||
private val imageAvailableListener = ImageReader.OnImageAvailableListener { reader ->
|
private val imageAvailableListener = ImageReader.OnImageAvailableListener { reader ->
|
||||||
try {
|
try {
|
||||||
val buffer = reader.acquireNextImage().planes.first().buffer
|
val image = reader.acquireNextImage()
|
||||||
|
val buffer = image.planes.first().buffer
|
||||||
val bytes = ByteArray(buffer.remaining())
|
val bytes = ByteArray(buffer.remaining())
|
||||||
buffer.get(bytes)
|
buffer.get(bytes)
|
||||||
|
image.close()
|
||||||
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, mSensorOrientation, mUseFrontCamera, mIsImageCaptureIntent).execute(bytes)
|
PhotoProcessor(mActivity, mTargetUri, mRotationAtCapture, mSensorOrientation, mUseFrontCamera, mIsImageCaptureIntent).execute(bytes)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
}
|
}
|
||||||
@ -338,7 +340,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
mMediaRecorder = MediaRecorder()
|
mMediaRecorder = MediaRecorder()
|
||||||
} else {
|
} else {
|
||||||
mImageReader = ImageReader.newInstance(currentResolution.width, currentResolution.height, ImageFormat.JPEG, 2)
|
mImageReader = ImageReader.newInstance(currentResolution.width, currentResolution.height, ImageFormat.JPEG, 2)
|
||||||
mImageReader!!.setOnImageAvailableListener(imageAvailableListener, mBackgroundHandler)
|
mImageReader!!.setOnImageAvailableListener(imageAvailableListener, null)
|
||||||
mMediaRecorder = null
|
mMediaRecorder = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,7 +597,10 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
}
|
}
|
||||||
|
|
||||||
val captureCallback = object : CameraCaptureSession.CaptureCallback() {
|
val captureCallback = object : CameraCaptureSession.CaptureCallback() {
|
||||||
override fun onCaptureCompleted(session: CameraCaptureSession, request: CaptureRequest, result: TotalCaptureResult) {}
|
override fun onCaptureCompleted(session: CameraCaptureSession, request: CaptureRequest, result: TotalCaptureResult) {
|
||||||
|
unlockFocus()
|
||||||
|
mActivity.toggleBottomButtons(false)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onCaptureFailed(session: CameraCaptureSession?, request: CaptureRequest?, failure: CaptureFailure?) {
|
override fun onCaptureFailed(session: CameraCaptureSession?, request: CaptureRequest?, failure: CaptureFailure?) {
|
||||||
super.onCaptureFailed(session, request, failure)
|
super.onCaptureFailed(session, request, failure)
|
||||||
@ -796,7 +801,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
if (mLastFocusX != 0f && mLastFocusY != 0f) {
|
if (mLastFocusX != 0f && mLastFocusY != 0f) {
|
||||||
focusArea(mLastFocusX, mLastFocusY, false)
|
focusArea(mLastFocusX, mLastFocusY, false)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: CameraAccessException) {
|
||||||
} finally {
|
} finally {
|
||||||
mCameraState = STATE_PREVIEW
|
mCameraState = STATE_PREVIEW
|
||||||
}
|
}
|
||||||
@ -1033,15 +1038,7 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
|||||||
|
|
||||||
override fun resumeCamera() = true
|
override fun resumeCamera() = true
|
||||||
|
|
||||||
override fun imageSaved() {
|
override fun imageSaved() {}
|
||||||
mImageReader?.close()
|
|
||||||
mActivity.toggleBottomButtons(false)
|
|
||||||
if (shouldLockFocus()) {
|
|
||||||
unlockFocus()
|
|
||||||
} else {
|
|
||||||
resetPreviewSession()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
|
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user