Moved RGB fix inside ImageQt class #5268
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #5266. A workaround suggested in that issue is to change the user code. This PR causes the original code mentioned there to work.
Pillow/src/PIL/ImageQt.py
Lines 203 to 205 in fdd8b68
This 'strange bug' is because at https://doc.qt.io/qt-5/qimage.html
QImage is expecting the 4th channel to be populated with 0xff (255). Calling
convert("RGBA")
in Pillow does this.Pillow/src/libImaging/Convert.c
Lines 421 to 431 in fdd8b68
Without 255 values, as seen in the issue, the display in Qt is very washed out.
This PR just documents the fix slightly better, and moves it from
toqpixmap()
to_toqclass_helper()
, so that it is also run when calling theImageQt.ImageQt
class (toqixmap()
still works, sincetoqpixmap()
callstoqimage()
, which returns an instance of theImageQt.ImageQt
class).