From 9b299132ef8912910df5a90b1628cc3af1efc54d Mon Sep 17 00:00:00 2001 From: Jon Lund Steffensen Date: Sun, 28 Dec 2014 22:58:54 -0500 Subject: colorramp: Use supplied gamma ramps as initial value This changes colorramp_fill() to base the ramp calculations on the existing values in the supplied tables, instead of basing it on a pure `i/size` value computed on the fly. All gamma adjustment methods are changed to explicitly initialize the ramps to the `i/size` value before calls to colorramp_fill(). --- src/colorramp.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/colorramp.c') diff --git a/src/colorramp.c b/src/colorramp.c index d732a18..fda75f2 100644 --- a/src/colorramp.c +++ b/src/colorramp.c @@ -297,9 +297,12 @@ colorramp_fill(uint16_t *gamma_r, uint16_t *gamma_g, uint16_t *gamma_b, &blackbody_color[temp_index+3], white_point); for (int i = 0; i < size; i++) { - gamma_r[i] = F((float)i/size, 0) * (UINT16_MAX+1); - gamma_g[i] = F((float)i/size, 1) * (UINT16_MAX+1); - gamma_b[i] = F((float)i/size, 2) * (UINT16_MAX+1); + gamma_r[i] = F((double)gamma_r[i]/(UINT16_MAX+1), 0) * + (UINT16_MAX+1); + gamma_g[i] = F((double)gamma_g[i]/(UINT16_MAX+1), 1) * + (UINT16_MAX+1); + gamma_b[i] = F((double)gamma_b[i]/(UINT16_MAX+1), 2) * + (UINT16_MAX+1); } } @@ -315,9 +318,9 @@ colorramp_fill_float(float *gamma_r, float *gamma_g, float *gamma_b, &blackbody_color[temp_index+3], white_point); for (int i = 0; i < size; i++) { - gamma_r[i] = F((float)i/size, 0); - gamma_g[i] = F((float)i/size, 1); - gamma_b[i] = F((float)i/size, 2); + gamma_r[i] = F((double)gamma_r[i], 0); + gamma_g[i] = F((double)gamma_g[i], 1); + gamma_b[i] = F((double)gamma_b[i], 2); } } -- cgit v1.2.3-70-g09d2