-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Avoid an extra copy/resample if imshow input has no alpha #27562
Conversation
2303cda
to
55fb0a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this get changed below as well in the else half of the interpolation_stage loop?
This is probably the best we can do to fix matplotlib#27554 at this time, without delving into re-writing the Agg resampler (which, as the Python code notes, does require RGBA.)
This is in the |
# No need to resample alpha or make a full array; NumPy will expand | ||
# this out and cast to uint8 if necessary when it's assigned to the | ||
# alpha channel below. | ||
output_alpha = (255 * alpha) if A.dtype == np.uint8 else alpha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be multiplying by 255 if it is a float, rather than if it is a uint8
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alpha
is always a 0-1 float; if the data is uint8
, then output alpha must be 0-255 instead.
PR summary
This is probably the best we can do to fix #27554 at this time, without delving into re-writing the Agg resampler (which, as the Python code notes, does require RGBA.)
Also adds a test, as it appears that nothing checked an RGB input with transparent
alpha
(and my original suggestion from #27554 (comment) using 255/1.0 passed tests even though it didn't work.)PR checklist