From c155677c4febece9a280208be11f2dd844fe22ad Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 22 Jun 2024 00:39:37 +1000 Subject: [PATCH] Removed support for Qt 5 --- Tests/test_imageqt.py | 19 +++++++------------ src/PIL/ImageQt.py | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Tests/test_imageqt.py b/Tests/test_imageqt.py index 88ad1f9ee..22cd674ce 100644 --- a/Tests/test_imageqt.py +++ b/Tests/test_imageqt.py @@ -41,18 +41,13 @@ def test_rgb() -> None: checkrgb(0, 0, 255) -def test_image() -> None: - modes = ["1", "RGB", "RGBA", "L", "P"] - qt_format = ImageQt.QImage.Format if ImageQt.qt_version == "6" else ImageQt.QImage - if hasattr(qt_format, "Format_Grayscale16"): # Qt 5.13+ - modes.append("I;16") - - for mode in modes: - im = hopper(mode) - roundtripped_im = ImageQt.fromqimage(ImageQt.ImageQt(im)) - if mode not in ("RGB", "RGBA"): - im = im.convert("RGB") - assert_image_similar(roundtripped_im, im, 1) +@pytest.mark.parametrize("mode", ("1", "RGB", "RGBA", "L", "P", "I;16")) +def test_image(mode: str) -> None: + im = hopper(mode) + roundtripped_im = ImageQt.fromqimage(ImageQt.ImageQt(im)) + if mode not in ("RGB", "RGBA"): + im = im.convert("RGB") + assert_image_similar(roundtripped_im, im, 1) def test_closed_file() -> None: diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index 293ba4941..7819ae9c1 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -152,7 +152,7 @@ def _toqclass_helper(im): elif im.mode == "RGBA": data = im.tobytes("raw", "BGRA") format = qt_format.Format_ARGB32 - elif im.mode == "I;16" and hasattr(qt_format, "Format_Grayscale16"): # Qt 5.13+ + elif im.mode == "I;16": im = im.point(lambda i: i * 256) format = qt_format.Format_Grayscale16