W3C home > Mailing lists > Public > www-svg@w3.org > July 2012

Re: Compositing math in SVG

From: Rik Cabanier <cabanier@gmail.com>
Date: Sat, 21 Jul 2012 15:02:58 -0700
Message-ID: <CAGN7qDB4b2Ub8RFuH+U8QW6sTfgtmh6cEOtSqBVRfp4q7usqug@mail.gmail.com>
To: Calculemus <calculemus1988@gmail.com>
Cc: steve@fenestra.com, www-svg@w3.org
On Sat, Jul 21, 2012 at 1:26 PM, Calculemus <calculemus1988@gmail.com>wrote:

> Having problems with the formulas from SVG spec...
>
> I tested the blend modes and my results match
> perfectly Photoshop and GIMP results, but only
> for regions in the image where alpha values
> are either 0 or 1 for the input images.
>
> If the top image for example has Opacity, or
> alpha 0.5 then my results are darker for some reason
> I can't figure out whole day.
>
> I am using the formulas for blend modes and Over compositing
> from SVG spec:
>
> http://www.w3.org/TR/SVGCompositing/
>
> What could possibly be the reason for this behaviour?
>
> The general formula is:
>
> A*aa*(1-ba) + B*ba*(1-aa) + aa*ba*Blend(A, B)
>

This formula will return you the color in premultiplied alpha.
I think you still need to calculate alpha of the end result and matte with
white to get the final color.

See example 4 in
https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#backdropexamples


>
> where A and B are non-premultiplied color values and aa and ba
> are alpha values.
>
> When aa and ba are both 1 my results are fine, the formula reduces
> to Blend(A,B). This confirms that I have all formulas
> for blend modes correct. It is the other part before
> Blend(A,B) that must somehow causing this problem.
>
> So, this is the case for all blend modes, not just for one or two.
> I wonder if the formula for compositing is correct?
> The blend formulas are correct  though.
>
Received on Saturday, 21 July 2012 22:03:27 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:51 GMT