From b724bf06c94fd35d3a6536cbfd9735bdc2cd870c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 18 Mar 2014 07:11:24 +0100 Subject: Apply gamma after brightness and termperature MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/colorramp.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/colorramp.c b/src/colorramp.c index cd43e7b..f1988d4 100644 --- a/src/colorramp.c +++ b/src/colorramp.c @@ -291,12 +291,11 @@ colorramp_fill(uint16_t *gamma_r, uint16_t *gamma_g, uint16_t *gamma_b, interpolate_color(alpha, &blackbody_color[temp_index], &blackbody_color[temp_index+3], white_point); +#define F(Y, C) pow((Y) * brightness * white_point[C], 1.0/gamma[C]) + for (int i = 0; i < size; i++) { - gamma_r[i] = pow((float)i/size, 1.0/gamma[0]) * - (UINT16_MAX+1) * brightness * white_point[0]; - gamma_g[i] = pow((float)i/size, 1.0/gamma[1]) * - (UINT16_MAX+1) * brightness * white_point[1]; - gamma_b[i] = pow((float)i/size, 1.0/gamma[2]) * - (UINT16_MAX+1) * brightness * white_point[2]; + 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); } } -- cgit v1.2.3-70-g09d2