Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Honouring the alpha attribute when creating composite images.#1955

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
pelson merged 4 commits intomatplotlib:masterfromWestacular:alpha-image-composite
May 13, 2013

Conversation

Westacular
Copy link
Contributor

I noticed some problems with the drawing of Images onto axes. Specifically, whenoption_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 workingat all for Cairo, it's perhaps better saved for a separate pull request.

@mdboom
Copy link
Member

👍 I agree we can save the Cairo fix for later. It looks as it the test images were perhaps not committed.

@Westacular
Copy link
ContributorAuthor

I've rebased/squashed this (with the formerly forgotten test images) and the Travis build is passing now.

@mdboom
Copy link
Member

👍

@@ -823,6 +825,16 @@
Image* thisim = static_cast<Image*>(tup[0].ptr());
ox = (long)Py::Int(tup[1]);
oy = (long)Py::Int(tup[2]);
if (tup[3].ptr() == Py_None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah, I think I agree. To maintain backward compatibility, maybe do:

if (tup.size() <= 2 || tup[3].ptr() == Py_None)

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

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 requestMay 13, 2013
Honouring the alpha attribute when creating composite images.
@pelsonpelson merged commit3e9f4a6 intomatplotlib:masterMay 13, 2013
@pelson
Copy link
Member

Another fantastic piece of work@Westacular. Cheers!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v1.3.x
Development

Successfully merging this pull request may close these issues.

3 participants
@Westacular@mdboom@pelson

[8]ページ先頭

©2009-2025 Movatter.jp