Skip to content

Commit

Permalink
Merge pull request #8159 from radarhere/qt6
Browse files Browse the repository at this point in the history
Removed support for Qt 5
  • Loading branch information
hugovk committed Jun 23, 2024
2 parents 1c8d270 + c155677 commit 0201707
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions Tests/test_imageqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,13 @@ def checkrgb(r: int, g: int, b: int) -> 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:
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/ImageQt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0201707

Please sign in to comment.