From fc3ce861cdab8606610726ce7c53f57d950c2407 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Thu, 14 May 2009 11:35:25 +0200 Subject: randr12: Fix calculation of gamma ramp values. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The reciprocal gamma value was missed in the first copy and this mistake was propagated to the second one. Signed-off-by: Michel Dänzer --- hw/xfree86/modes/xf86Crtc.c | 6 +++--- hw/xfree86/modes/xf86RandR12.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c index 1b241cd33..0ab2f3df9 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c @@ -2228,19 +2228,19 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green, red[i] = i << 8; else red[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)gamma_red) * (double)(size - 1) * 256); + 1. / (double)gamma_red) * (double)(size - 1) * 256); if (gamma_green == 1.0) green[i] = i << 8; else green[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)gamma_green) * (double)(size - 1) * 256); + 1. / (double)gamma_green) * (double)(size - 1) * 256); if (gamma_blue == 1.0) blue[i] = i << 8; else blue[i] = (CARD16)(pow((double)i/(double)(size - 1), - (double)gamma_blue) * (double)(size - 1) * 256); + 1. / (double)gamma_blue) * (double)(size - 1) * 256); } /* Default size is 256, so anything else is failure. */ diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c index f941a3b4a..c71cfe5c3 100644 --- a/hw/xfree86/modes/xf86RandR12.c +++ b/hw/xfree86/modes/xf86RandR12.c @@ -1703,7 +1703,7 @@ gamma_to_ramp(float gamma, CARD16 *ramp, int size) if (gamma == 1.0) ramp[i] = i << 8; else - ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), gamma) + ramp[i] = (CARD16)(pow((double)i / (double)(size - 1), 1. / gamma) * (double)(size - 1) * 256); } } -- cgit v1.2.3