From cfc86a38c969494f436145a41895905beabf1080 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Fri, 27 Oct 2023 10:19:36 +0100 Subject: [PATCH] Fix colour order in QT preview for some RGB formats RGB888 and XRGB8888 were being displayed with a red-blue swap. Signed-off-by: David Plowman --- picamera2/previews/q_picamera2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/picamera2/previews/q_picamera2.py b/picamera2/previews/q_picamera2.py index a01d1e1b..c15bb5b5 100644 --- a/picamera2/previews/q_picamera2.py +++ b/picamera2/previews/q_picamera2.py @@ -188,7 +188,8 @@ def render_request(self, completed_request): width = min(img.shape[1], stream_config["size"][0]) width -= width % 4 img = np.ascontiguousarray(img[:, :width, :3]) - qim = QImage(img.data, width, img.shape[0], QImage.Format_RGB888) + fmt = QImage.Format_BGR888 if stream_config['format'] in ('RGB888', 'XRGB8888') else QImage.Format_RGB888 + qim = QImage(img.data, width, img.shape[0], fmt) pix = QPixmap(qim) # Add the pixmap to the scene if there wasn't one, or replace it if the images have # changed size.