{{ message }}
Honouring the alpha attribute when creating composite images. - #1955
Merged
Merged
Conversation
Member
Contributor
Author
|
I've rebased/squashed this (with the formerly forgotten test images) and the Travis build is passing now. |
Member
|
👍 |
Member
There was a problem hiding this comment.
I'm not sure about this - does it not set an IndexError? (http://docs.python.org/2/c-api/tuple.html#PyTuple_GetItem)
I wonder if we'd be better checking the tuple's size?
Member
There was a problem hiding this comment.
Yeah, I think I agree. To maintain backward compatibility, maybe do:
if (tup.size() <= 2 || tup[3].ptr() == Py_None)
Contributor
Author
There was a problem hiding this comment.
OK. Everything that calls this in the codebase (all … 2 instances) was updated with the added parameter, but I'd forgotten the possibility that user code might call this.
pelson
added a commit
that referenced
this pull request
May 13, 2013
Honouring the alpha attribute when creating composite images.
Member
2 tasks
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.

I noticed some problems with the drawing of Images onto axes. Specifically, when
option_image_nocomposite()is False and a single composite image is created (which seems to be the default for most backends), the alpha attribute of the Image objects was being ignored in the compositing process.I've fixed that by multiplying the alpha component of each pixel with the attribute of the image, if set, during the process of compositing/blending the images together.
I've set up a test for this, as well, but getting the correct results from it depends on the changes from #1868.
In the process of testing this, I discovered that for output formats other than PNG, the Cairo backend was entirely failing to render images. I fixed that issue, however, a problem still remains: the Cairo image blending algorithms assume that pixel values are premultiplied by their alpha components, which is not currently being done in the process of converting image buffers for use by Cairo. For non-opaque images where rgb values exceed the alpha value, the result can be pretty weird and psychedelic. I can take a crack at fixing this, but it's a more involved change, and given that previously images weren't working at all for Cairo, it's perhaps better saved for a separate pull request.