From 6d170f33a6a47116df17dd2798ab0463dfcc5ee2 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Sun, 16 Sep 2018 21:28:04 -0300 Subject: [PATCH] Add legacy implementation stup --- .../cameraview/SnapshotPictureRecorder.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/SnapshotPictureRecorder.java b/cameraview/src/main/java/com/otaliastudios/cameraview/SnapshotPictureRecorder.java index 3b934043..46e26517 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/SnapshotPictureRecorder.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/SnapshotPictureRecorder.java @@ -4,6 +4,7 @@ import android.graphics.ImageFormat; import android.graphics.Rect; import android.graphics.YuvImage; import android.hardware.Camera; +import android.opengl.GLSurfaceView; import java.io.ByteArrayOutputStream; @@ -17,6 +18,7 @@ class SnapshotPictureRecorder extends PictureRecorder { private Camera1 mController; private Camera mCamera; + private CameraPreview mPreview; private AspectRatio mOutputRatio; private Size mSensorPreviewSize; private int mFormat; @@ -24,6 +26,7 @@ class SnapshotPictureRecorder extends PictureRecorder { SnapshotPictureRecorder(PictureResult stub, Camera1 controller, Camera camera, AspectRatio viewRatio) { super(stub, controller); mController = controller; + mPreview = controller.mPreview; mCamera = camera; mOutputRatio = viewRatio; mFormat = mController.mPreviewFormat; @@ -32,6 +35,19 @@ class SnapshotPictureRecorder extends PictureRecorder { @Override void take() { + if (mPreview instanceof GLCameraPreview) { + takeGl((GLCameraPreview) mPreview); + } else { + takeLegacy(); + } + } + + private void takeGl(GLCameraPreview preview) { + // TODO implement. + takeLegacy(); + } + + private void takeLegacy() { mCamera.setOneShotPreviewCallback(new Camera.PreviewCallback() { @Override public void onPreviewFrame(final byte[] yuv, Camera camera) {