This is one of the reasons that we prefer associated alpha (a.k.a. 
"premultiplied" color) -- it can represent pixel situations that unassociated 
alpha simply cannot, such as completely transparent pixels that nonetheless 
have color.

If possible, I think you should ignore the /0 issue, and work out the math to 
express everything in terms of the unassociated alpha, as we did with "screen" 
in earlier discussions.

Exactly which blend mode are you stuck on?


On Jul 19, 2012, at 3:32 PM, Stefan Stavrev wrote:

> I am working on the blend modes formulas and 
> I am not sure what to do with a/0:
> 
> A = a/aa
> 
> A - non-pre-multiplied color
> a - pre-multiplied color
> aa - alpha value
> 
> The only reasonable thing to do that I can think of is:
> 
> Let 'ba' mean alpha value for a pixel in the other input image B.
> 
> 1. if (aa==0 && ba!=0) then copy the values from image B at that pixel, to 
> result image R.
> 2. if (aa!=0 && ba==0) then copy the values from image A at that pixel, to 
> result image R.
> 3. if (aa==0 && ba==0) then set that pixel to (0,0,0,0) in result image R.
> 
> So, if only one alpha value is 0, for a pixel in image A or B,
> then that is the same case as if one of the iterators for the input images
> is not valid, and the other one is valid, so we just copy values from the 
> valid one.
> But if both alpha values are 0, then that is the same as if both
> iterators are invalid, in which case the result is (0,0,0,0).
> 

--
Larry Gritz
[email protected]


_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to