diff --git a/src/cairo-color.c b/src/cairo-color.c index 9c852559e..c2a11a177 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 diff --git a/test/reference/pthread-similar.ref.png b/test/reference/pthread-similar.ref.png index a22210db8..c8763ba0e 100644 Binary files a/test/reference/pthread-similar.ref.png and b/test/reference/pthread-similar.ref.png differ diff --git a/test/reference/record-paint-alpha.ref.png b/test/reference/record-paint-alpha.ref.png index ab7ce3e04..487b8b622 100644 Binary files a/test/reference/record-paint-alpha.ref.png and b/test/reference/record-paint-alpha.ref.png differ diff --git a/test/reference/record90-paint-alpha.argb32.ref.png b/test/reference/record90-paint-alpha.argb32.ref.png index 57aa95d37..5e9cb58d9 100644 Binary files a/test/reference/record90-paint-alpha.argb32.ref.png and b/test/reference/record90-paint-alpha.argb32.ref.png differ diff --git a/test/reference/record90-paint-alpha.rgb24.ref.png b/test/reference/record90-paint-alpha.rgb24.ref.png index 57aa95d37..5e9cb58d9 100644 Binary files a/test/reference/record90-paint-alpha.rgb24.ref.png and b/test/reference/record90-paint-alpha.rgb24.ref.png differ diff --git a/test/reference/xcb-huge-image-shm.ref.png b/test/reference/xcb-huge-image-shm.ref.png index a0b24c8aa..5c274f824 100644 Binary files a/test/reference/xcb-huge-image-shm.ref.png and b/test/reference/xcb-huge-image-shm.ref.png differ diff --git a/test/reference/xcb-huge-subimage.ref.png b/test/reference/xcb-huge-subimage.ref.png index a0b24c8aa..5c274f824 100644 Binary files a/test/reference/xcb-huge-subimage.ref.png and b/test/reference/xcb-huge-subimage.ref.png differ