From 95d8a3f7600073b4abe869078cf3db1d8497c60a Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Mon, 21 Oct 2013 15:26:47 -0400 Subject: colorramp: Fix slight flicker caused by improper scaling of gamma ramp values Values generated by colorramp_fill() will be a maximum of i * 256 - 1, due to the use of UINT16_MAX. Simplest fix ought to be using (UINT16_MAX+1), which is safe, as the maximum value (255 * 256) still fits in a uint16. (Thanks to Sean Hildebrand) --- src/colorramp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/colorramp.c') diff --git a/src/colorramp.c b/src/colorramp.c index ed399f8..4d32d7e 100644 --- a/src/colorramp.c +++ b/src/colorramp.c @@ -139,10 +139,10 @@ colorramp_fill(uint16_t *gamma_r, uint16_t *gamma_g, uint16_t *gamma_b, for (int i = 0; i < size; i++) { gamma_r[i] = pow((float)i/size, 1.0/gamma[0]) * - UINT16_MAX * brightness * white_point[0]; + (UINT16_MAX+1) * brightness * white_point[0]; gamma_g[i] = pow((float)i/size, 1.0/gamma[1]) * - UINT16_MAX * brightness * white_point[1]; + (UINT16_MAX+1) * brightness * white_point[1]; gamma_b[i] = pow((float)i/size, 1.0/gamma[2]) * - UINT16_MAX * brightness * white_point[2]; + (UINT16_MAX+1) * brightness * white_point[2]; } } -- cgit v1.2.3-70-g09d2