[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [E-devel] Premultiply or not

On 6/26/06, David Seikel <onefang@gmail.com> wrote:
On Mon, 26 Jun 2006 06:37:21 GMT "jose_ogp@juno.com"
<jose_ogp@juno.com> wrote:

>     It's definitely a 'plus' for evas to move with working
> in premul color space internally (and recall: a,r,g,b is premul
> iff a >= r,g,b). There are many reasons for this.. some I've
> already stated here

Just to clarify things, is it a case of "most of the pixel twiddling
needs to have this multiplication step done anyway, so we might as well
pre-multiply at the beginning to avoid lots of lengthy multiplications
happening deep in pixel handling loops, and some external sources of
pixels already come in premul form anyway"?

I'm curious about this as well. If I understand correctly, premul image data is only handy for when you actually start compositing alpha-based pixel data? Most single-image operations just use simple pixel-by-pixel or image-kernel-based operations, with or without alpha. The alpha only starts to 'mean' something when you actually perform the compositing with other image data. In that case I fail to see why it would be handy to have premul data in the stage where compositing isn't done yet. And for the same reason I fail to see why it would be necessary for external sources to hand premul data to Evas (except for performance of course).

I also find it counter-intuitive to do a set_color with a premul color. I kind of see this as your user interface to your library. I've yet to see one photoshop/gimp/inkscape-or-clone which has you manipulate colors in premul, even though it handles them like that internally. But of course, Evas is not a painting program, so why shouldn't premul be handled....

As a counterpoint, Cairo for example (IIRC), takes only non-premul colors in for setting colors and gradient stops, and does all the premul stuff in the engine itself, after which it spits out premul images, for easy composting. You can de-premul those at will afterwards. That system works too, and it is pretty intuitive. However it is kind of a shock when you first discover that you pump non-premul in and it spits premul out.

What I do find very very interesting, is the fact that premul colors allow you to 'glow' a color by pushing the color value over the alpha value (if you violate the a >= r,g,b property). That is something that IS very handy and I can't think of any easy way to accomplish this with non-premul data. So I do believe that using premul gives you more possibilities as well.