From a165ce946f2816c78a6b8ea038863756e8912df4 Mon Sep 17 00:00:00 2001 From: James Hodgson Date: Fri, 7 Oct 2022 14:53:08 +0100 Subject: [PATCH] #22 explicitly set bytearray size --- src/picam/picam1.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/picam/picam1.py b/src/picam/picam1.py index f2182ba..6442fa7 100644 --- a/src/picam/picam1.py +++ b/src/picam/picam1.py @@ -36,10 +36,12 @@ class PiCam1(PiCam): def capture(self, preview: bool = False) -> bytearray: # Bytes to hold output buffer - out = bytearray() bytes_stream = BytesIO() - if not preview: + if preview: + out = bytearray(self.preview_resolution[0] * self.preview_resolution[1]) + else: + out = bytearray(self.capture_resolution[0] * self.capture_resolution[1]) # If preview we'll already have the right resolution self.set_camera_resolution(self.capture_resolution)