Skip to content

Commit

Permalink
Fix colour order in QT preview for some RGB formats
Browse files Browse the repository at this point in the history
RGB888 and XRGB8888 were being displayed with a red-blue swap.

Signed-off-by: David Plowman <[email protected]>
  • Loading branch information
davidplowman committed Oct 27, 2023
1 parent ecc168b commit cfc86a3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion picamera2/previews/q_picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cfc86a3

Please sign in to comment.