[cairo] Use 8-bit colour values internally
Bill Spitzak
spitzak at d2.com
Tue Aug 23 15:47:24 PDT 2005
Jason Dorje Short wrote:
>> - color->alpha_short = color->alpha * CAIRO_COLOR_ONE_MINUS_EPSILON;
>> + color->alpha_char = floor (color->alpha * 255.0 + 0.5);
>
> Looks like the uniform-distribution hack here is trying to do the same
> thing you're doing with rounding (otherwise 0.{9} would never give
> COLOR_MAX, always COLOR_MAX-1). Clearly rounding is more accurate
> though (if I understand rightly what this code does).
Actually the uniform-distribution hack produces more desirable results
in that the range 0.0-1.0 is divided into equal-sized bins that land in
each resulting pixel value. The rounding version makes the bin for the
largest and smallest pixel values only half-size.
PS: having made this mistake personally many times, I should know. Use
the multiply and floor, not rounding.
More information about the cairo
mailing list