From b59306a3fd931f911701ba45730866bd273f5cbb Mon Sep 17 00:00:00 2001 From: Ashley Anderson Date: Wed, 6 Dec 2023 11:14:47 -0500 Subject: [PATCH] Ensure QImage is ARGB32 before converting to numpy --- src/magicgui/backends/_qtpy/widgets.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/magicgui/backends/_qtpy/widgets.py b/src/magicgui/backends/_qtpy/widgets.py index a94bd3665..b99c60501 100644 --- a/src/magicgui/backends/_qtpy/widgets.py +++ b/src/magicgui/backends/_qtpy/widgets.py @@ -181,6 +181,8 @@ def _mgui_render(self) -> numpy.ndarray: ) from None img = self._qwidget.grab().toImage() + if img.format() != QImage.Format_ARGB32: + img = img.convertToFormat(QImage.Format_ARGB32) bits = img.constBits() h, w, c = img.height(), img.width(), 4 if qtpy.API_NAME.startswith("PySide"):