On Mon, 2010-11-22 at 16:06 +0100, Tavmjong Bah wrote:
Note: This calculation is still using sRGB when it should be using linearRGB. I've verified that it gives the correct results when using individually solid red, green, and blue as masks (matching Batik and Firefox). If one uses a mask of 50% gray, there is a significant difference between Inkscape and other renderers. I've attached a test file to bug 597974:
To convert sRGB to linearRGB I propose to add three look-up tables, one for each color. The values will include both the conversion plus the luminance to alpha values. I've done a quick test and this seems to work.
const unsigned int srgb_to_linear_r[] = { 0, 0, 0, 0, 1, 2, 3, 5, 6, 8, 11, 13, 16, 19, 23, 27, ... }
m = NR_PREMUL_112 ( (srgb_to_linear_r[s[0]] + srgb_to_linear_g[s[1]] + srgb_to_linear_b[s[2]] ) >> 8, s[3]); d[0] = FAST_DIV_ROUND < 255 > (m);
This would fix Inkscape's display but not Cairo PDF export. The latter is more problematic as the pixel data is already multiplied by alpha.
Tav