From 6aca23cfa32889f9dae83f5374d216662cb7de8e Mon Sep 17 00:00:00 2001 From: Christopher Bruns Date: Sun, 28 Nov 2021 19:34:14 -0800 Subject: [PATCH] Support 16-bit grayscale ImageQt conversion. --- src/PIL/ImageQt.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PIL/ImageQt.py b/src/PIL/ImageQt.py index e142f1f27..f10de3258 100644 --- a/src/PIL/ImageQt.py +++ b/src/PIL/ImageQt.py @@ -108,7 +108,7 @@ def align8to32(bytes, width, mode): converts each scanline of data from 8 bit to 32 bit aligned """ - bits_per_pixel = {"1": 1, "L": 8, "P": 8}[mode] + bits_per_pixel = {"1": 1, "L": 8, "P": 8, "I;16": 16}[mode] # calculate bytes per line and the extra padding if needed bits_per_line = bits_per_pixel * width @@ -167,6 +167,8 @@ def _toqclass_helper(im): elif im.mode == "RGBA": data = im.tobytes("raw", "BGRA") format = qt_format.Format_ARGB32 + elif im.mode == "I;16": + format = qt_format.Format_Grayscale16 else: if exclusive_fp: im.close()