Fix alpha handling when flattening images for vector backends - #32107
Merged
Conversation
ayshih
force-pushed
the
flatten_images_with_alpha
branch
5 times, most recently
from
July 24, 2026 02:52
ca23deb to
86aeef6
Compare
ayshih
force-pushed
the
flatten_images_with_alpha
branch
from
July 24, 2026 03:16
86aeef6 to
98a50a6
Compare
ayshih
marked this pull request as ready for review
July 24, 2026 03:52
tacaswell
approved these changes
Aug 6, 2026
QuLogic
approved these changes
Aug 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR summary
This PR fixes a bug when flattening images for vector backends and a non-unity scalar alpha is specified. Image flattening is when the Agg resampler is used to flatten a sequence of images into a single image so that only a single image needs to be drawn by the backend, and is enabled by default. When an image is added with a scalar alpha (i.e.,
imshow(..., alpha=...)), that scalar alpha is mistakenly applied twice during flattening: (1) when preparing the image to be resampled, and (2) when resampling the prepared image into the output buffer. For example, an image that is intended to have an alpha of 0.6 ends up in the flattened image as if it had an alpha of 0.36 (0.6 squared). This is the root cause of #8847.I also added a clarifying comment for future maintainers because I got tripped up with inspecting the code. The Agg resampler typically assumes that the input image is in premultiplied alpha space (cf. #31021 (comment)), except when the input image is uint8 (code). I forgot about that exception.
Fixes #8847
AI Disclosure
PR checklist