Check if installed Qt version supports Format_Grayscale16

This commit is contained in:
Christopher Bruns 2021-11-29 19:38:57 -08:00 committed by Andrew Murray
parent b1cc094f57
commit e87745d9ec
2 changed files with 5 additions and 2 deletions

View File

@ -42,8 +42,11 @@ def test_rgb():
def test_image(): def test_image():
for mode in ("1", "RGB", "RGBA", "L", "P", "I;16"): for mode in ("1", "RGB", "RGBA", "L", "P"):
ImageQt.ImageQt(hopper(mode)) ImageQt.ImageQt(hopper(mode))
qt_format = ImageQt.QImage.Format if ImageQt.qt_version == "6" else ImageQt.QImage
if hasattr(qt_format, "Format_Grayscale16"): # Qt 5.13+
ImageQt.ImageQt(hopper("I;16"))
def test_closed_file(): def test_closed_file():

View File

@ -167,7 +167,7 @@ def _toqclass_helper(im):
elif im.mode == "RGBA": elif im.mode == "RGBA":
data = im.tobytes("raw", "BGRA") data = im.tobytes("raw", "BGRA")
format = qt_format.Format_ARGB32 format = qt_format.Format_ARGB32
elif im.mode == "I;16": elif im.mode == "I;16" and hasattr(qt_format, "Format_Grayscale16"): # Qt 5.13+
format = qt_format.Format_Grayscale16 format = qt_format.Format_Grayscale16
else: else:
if exclusive_fp: if exclusive_fp: