Skip to content

Correct image by scaling pixels#1

Merged
cmbruns merged 1 commit intocmbruns:cmbruns/grayscale-16-bit-qimagefrom
radarhere:cmbruns/grayscale-16-bit-qimage
Dec 13, 2021
Merged

Correct image by scaling pixels#1
cmbruns merged 1 commit intocmbruns:cmbruns/grayscale-16-bit-qimagefrom
radarhere:cmbruns/grayscale-16-bit-qimage

Conversation

@radarhere
Copy link
Copy Markdown

Fixes python-pillow#5856 (comment) using your suggestion from python-pillow#5856 (comment)

I've also modified the test to check that the image contents are similar after roundtripping through ImageQt.

data = im.tobytes("raw", "BGRA")
format = qt_format.Format_ARGB32
elif im.mode == "I;16" and hasattr(qt_format, "Format_Grayscale16"): # Qt 5.13+
im = im.point(lambda i: i * 255)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On reflection I believe the correct multiplier here should be 256, not 255. So the maximum intensity would be 255*256, which still falls within the unsigned 16-bit integer range.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I've corrected my commit in your PR.

@cmbruns cmbruns merged commit e129fab into cmbruns:cmbruns/grayscale-16-bit-qimage Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants