diff --git a/app/src/main/java/com/codigoparallevar/minicards/parts/android/CameraStreamer.java b/app/src/main/java/com/codigoparallevar/minicards/parts/android/CameraStreamer.java index 9aff9b7..548ead1 100644 --- a/app/src/main/java/com/codigoparallevar/minicards/parts/android/CameraStreamer.java +++ b/app/src/main/java/com/codigoparallevar/minicards/parts/android/CameraStreamer.java @@ -69,6 +69,8 @@ public class CameraStreamer implements Part { private ImageReader imageReader = null; private HandlerThread _thread = null; private Handler _handler = null; + private static final int CAPTURE_IMAGE_WIDTH = 256; + private static final int CAPTURE_IMAGE_HEIGHT = 256; private CameraStreamer(String id, PartGrid partGrid, int left, int top, int right, int bottom) { _id = id; @@ -335,10 +337,14 @@ public class CameraStreamer implements Part { } } - this.imageReader = ImageReader.newInstance(100, 100, ImageFormat.JPEG, 30); + this.imageReader = ImageReader.newInstance(CAPTURE_IMAGE_WIDTH, CAPTURE_IMAGE_HEIGHT, ImageFormat.JPEG, 30); this.imageReader.setOnImageAvailableListener((ImageReader.OnImageAvailableListener) newImageReader -> { Image latestImage = newImageReader.acquireLatestImage(); + if (latestImage == null) { + return; + } + CameraStreamer.this.onNewImage(latestImage); latestImage.close(); }, new Handler());