Hi Thomas.

I’ve been looking in to why the reference images in the repository often
are different from the images that are generated when I run regard.  The
main difference seems to be when non-opaque colours are composited.

As an example, I took a look at the second row fourth column sub-test of
samples/tests/spec/rendering/paintOpacity.svg, specifically one of the
pixels that is the 0.5 opacity gold painted on the opaque #eee
background square.

The reference image in the repository is
http://svn.apache.org/repos/asf/xmlgraphics/batik/trunk/test-references/samples/tests/spec/rendering/paintOpacity.png
and the image generated on my machine is
http://mcc.id.au/temp/2007/paintOpacity.png.  The PNGs themselves are
identical except for the IDAT chunk.

In the repository reference image, the pixel value is
rgba(224, 222, 118, 255), while in my image it is
rgba(246, 226, 119, 255).

Taking the alpha compositing rules from
http://www.w3.org/TR/SVG11/masking.html#SimpleAlphaBlending, this is my
calculation of the pixel value:

  // Premultiplied #eee background

  Ca = 1
  Cr = 238
  Cg = 238
  Cb = 238

  // Premultiplied 0.5 opacity gold rgb(255,215,0)

  Ea = trunc(trunc(0.5 * 255) / 255) = 0.49804
  Er = trunc(Ea * 255)               = 127
  Eg = trunc(Ea * 215)               = 107
  Eb = trunc(Ea * 0)                 = 0

  // Premultiplied final pixel value

  Ca' = trunc(1 - (1 - Ea) * (1 - Ca))
      = trunc(1 - 0.50196  * 0)
      = 1

  Cr' = trunc((1 - Ea) * Cr  + Er)
      = trunc(0.50196  * 238 + 127)
      = 246

  Cg' = trunc((1 - Ea) * Cg  + Eg)
      = trunc(0.50196  * 238 + 107)
      = 226

  Cb' = trunc((1 - Ea) * Cb  + Eb)
      = trunc(0.50196  * 238 + 0)
      = 119

and un-premultiplied this is the same as rgb(246, 226, 119, 255), which
matches the value in my image.  So my question is: are the reference
images in the repository wrong?  I’m not an expert on colour, so I don’t
know if there are other factors (colour spaces that the compositing
could occur in, for example) that would allow the values in the
repository reference image.  Any ideas?

Thanks,

Cameron

-- 
Cameron McCormack, http://mcc.id.au/
        xmpp:[EMAIL PROTECTED]  ▪  ICQ 26955922  ▪  MSN [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to