Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct image by scaling pixels #1

Conversation

radarhere
Copy link

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.

@@ -168,6 +168,8 @@ def _toqclass_helper(im):
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
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
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
2 participants