Re: [cairo] RFC: More accurate color conversion

James Cloos <cloos-GRsvFm/Gh/[email protected]>
Newsgroups gmane.comp.graphics.pixman,gmane.comp.lib.cairo
Message-ID <[email protected]>
>>>>> "CW" == Carl Worth <[email protected]> writes:

CW> But then you simply assert that the conversion from integer to
CW> floating-point must be f(i) = i/65535.0. What's the justification for
CW> this?

When I looked into this many moons ago, I concluded that the best option
is to multiply (with saturation) by IMAX+1 and divide by IMAX.  Ie, what
cairo currently does.

Dividing by IMAX generates an infinitely repeating value which best
places the integer value w/in the interval which rounds to said integer.

This is akin to mapping {0,...,9} to {0/9,...,9/9} generating the
decimal expansions 0, .111..., .222..., .333,... et cetera.

It is widely accepted that when expanding an 8bit value to 16 bit, one
should duplicate the bits, eg by multiplying by 257.  Dividing by IMAX
generates a floating point value which accomplishes that same goal.

-JimC
-- 
James Cloos <cloos-GRsvFm/Gh/[email protected]>         OpenPGP: 1024D/ED7DAEA6
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.