diff options
Diffstat (limited to 'src/cairo-color.c')
-rw-r--r--[-rwxr-xr-x] | src/cairo-color.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/cairo-color.c b/src/cairo-color.c index 9c852559e..c2a11a177 100755..100644 --- a/src/cairo-color.c +++ b/src/cairo-color.c @@ -78,18 +78,13 @@ _cairo_stock_color (cairo_stock_t stock) } /* Convert a double in [0.0, 1.0] to an integer in [0, 65535] - * The conversion is designed to divide the input range into 65536 - * equally-sized regions. This is achieved by multiplying by 65536 and - * then special-casing the result of an input value of 1.0 so that it - * maps to 65535 instead of 65536. + * The conversion is designed to choose the integer i such that + * i / 65535.0 is as close as possible to the input value. */ uint16_t _cairo_color_double_to_short (double d) { - uint32_t i; - i = (uint32_t) (d * 65536); - i -= (i >> 16); - return i; + return d * 65535.0 + 0.5; } static void |