diff options
author | James Cloos <cloos@jhcloos.com> | 2012-05-08 17:55:10 -0400 |
---|---|---|
committer | James Cloos <cloos@jhcloos.com> | 2012-05-08 17:55:10 -0400 |
commit | afc153a5b4fc58ae70dc214f61a71b1a8c855f06 (patch) | |
tree | 6fee7c8d01e0e5d44aded7ceb9fc71bd408ac25e | |
parent | e501c34d4937d5e6f19abd29f1ec7f95faa3bb55 (diff) |
Fix RANDR’s gamma_to_ramp().
In order to generate a 256-entry ramp in [0,65535] which covers the full
range, one must mupliply eight-bit values not by 256 but rather by 257.
Many years back – well before the RANDR extension was written, and
before xorg@fdo – a similar bug fix was made to the DIX for converting
client-supplied eight-bit color values into sixteen-bit values.
Noticed by: Elle Stone and Graeme Gill.
Signed-off-by: James Cloos <cloos@jhcloos.com>
-rw-r--r-- | hw/xfree86/modes/xf86RandR12.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index a773c34c6..aca0734e0 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1679,11 +1679,11 @@ gamma_to_ramp(float gamma, CARD16 *ramp, int size) for (i = 0; i < size; i++) { if (gamma == 1.0) - ramp[i] = i << 8; + ramp[i] = i | i << 8; else ramp[i] = (CARD16) (pow((double) i / (double) (size - 1), 1. / gamma) - * (double) (size - 1) * 256); + * (double) (size - 1) * 257); } } |