Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-22 Thread Daniel Hyams
Michael: I commented on the patch here: https://github.com/matplotlib/matplotlib/issues/545 In short...it works! -- The demand for IT networking professionals continues to grow, and the demand for specialized

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-21 Thread Michael Droettboom
Thanks for looking into this deeper. Agg requires image buffers to be premultiplied, as described in the third bullet point here. (It's not exactly clear, to say the least, but that's what I take it to mean, and also from reading the code).

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-21 Thread Daniel Hyams
All sounds reasonable Mike; I do agree that patching the agg source code is not that desirable; I was operating under the (incorrect) assumption that most, if not all, backends used straight alpha. I'll certainly test the patch tonight, but I can only test it under wxAgg reasonably, which is one

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-21 Thread Michael Droettboom
On 10/21/2011 09:49 AM, Daniel Hyams wrote: All sounds reasonable Mike; I do agree that patching the agg source code is not that desirable; I was operating under the (incorrect) assumption that most, if not all, backends used straight alpha. I'll certainly test the patch tonight, but I can

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-21 Thread Benjamin Root
On Friday, October 21, 2011, Michael Droettboom md...@stsci.edu wrote: On 10/21/2011 09:49 AM, Daniel Hyams wrote: All sounds reasonable Mike; I do agree that patching the agg source code is not that desirable; I was operating under the (incorrect) assumption that most, if not all, backends

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-20 Thread Daniel Hyams
I've looked all over the place through both the Python and C code, and I don't see any premultiplication of alphas at any stage before the pixels are passed off to agg, and neither can I find any place where the alphas are unmultiplied on the way back from agg to the backend for rendering. It's

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-19 Thread Michael Droettboom
You are right that Agg is doing the resizing here. Agg expects premultiplied alpha. See [1] for information about what that means. [1] http://en.wikipedia.org/wiki/Alpha_compositing After Agg interpolates the pixel values, to prevent oversaturation it truncates all values to be less than

Re: [Matplotlib-users] strange behavior of images when they have an alpha channel [resend]

2011-10-19 Thread Daniel Hyams
Ah, thanks so much Michael! That explanation helps a great deal; I was always considering things in straight alpha format, not even knowing that there was alternative. I'll play with this tonight; I don't see any problem getting the thing working, though, now that I know what agg expects to