[cairo] RFC: More accurate color conversion

Wolfgang Draxinger wdraxinger.maillist at draxit.de
Sat Oct 5 02:05:55 PDT 2013


On Sat, 05 Oct 2013 03:02:53 +0200
sandmann at cs.au.dk (Søren Sandmann) wrote:

> that serves as the canonical way to convert a double-precision color
> to a uint16_t normalized color. As the comment says, the function
> divides the input range into 65536 equal sized regions, and then it
> maps each region to an integer.
> 
> The function was written following this mail from Carl:
> 
>     http://lists.freedesktop.org/archives/cairo/2006-August/007709.html
> 
> in which among other things he argues that an alternative algorithm:
> 
>     i = floor (f * 65535 + 0.5)
> 
> (...)

I'd like to throw in this little paper, discussing the problem of
floating point <-> integer range conversion at depth: 

http://kaba.hilvi.org/homepage/programming/range/RangeConversion.pdf


Regards

Wolfgang


More information about the cairo mailing list