[cairo] Pixel color rounding issue
Alejandro Garcia Castro
alex at igalia.com
Tue Dec 7 02:09:28 PST 2010
Hi,
I'm working in WebKitGTK+ project, we have found a issue regarding
colors in some of the tests we are running. These tests are run
through all the ports and we try to share results with other graphical
engines. After commeting it with Company, in this case we would like
to check with you if in this case this is something expected and we
should generate different results for cairo/webkitgtk or something we
would like to change.
These tests are using the canvas tag to render a path with a color an
checking the pixels to test if the color set is the same in the pixel.
For cairo, setting a RGBA of (255, 20, 0, 0.5) results in a pixel with
(255, 18, 0, 0.5). The result comes due to the different conversions of
color for it's representation:
double -> 4 uint16 (cairo) -> 1 uint32 (pixman)
The first one does not add much error but in the second one we are
truncating the color like:
static uint32_t
color_to_uint32 (const pixman_color_t *color)
{
return
(color->alpha >> 8 << 24) |
(color->red >> 8 << 16) |
(color->green & 0xff00) |
(color->blue >> 8);
}
Due to premultiplication if alpha is big the rounding errors getting
the color are bigger but we were wondering if it would make sense to
round instead of trunc in this case to make it more accurate.
Anyway, it is true this is an issue for the users because the result
is similar, just a matter of testing correctness. I've attached a
cairo only test to check the issue.
Thanks for the comments in advance.
br
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_color.c
Type: text/x-csrc
Size: 1002 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20101207/a3e37272/attachment.c>
More information about the cairo
mailing list