Fix alpha handling when flattening images for vector backends#32107
Draft
ayshih wants to merge 2 commits into
Draft
Fix alpha handling when flattening images for vector backends#32107ayshih wants to merge 2 commits into
ayshih wants to merge 2 commits into
Conversation
ayshih
force-pushed
the
flatten_images_with_alpha
branch
from
July 23, 2026 17:03
2c07ff7 to
79eb786
Compare
ayshih
force-pushed
the
flatten_images_with_alpha
branch
from
July 23, 2026 17:26
79eb786 to
cccfc55
Compare
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 two bugs when flattening images for vector backends and alpha is not 1. 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 on by default.
imshow(..., alpha=...)), that scalar alpha is mistakenly applied twice: (1) when making the image to be resampled, and (2) when resampling the image into the common 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 Agg alpha image compositor differs from Matplotlib's software image compositor #8847.composite_imageshad not been updated accordingly.Fixes #8847
AI Disclosure
PR checklist