--- ray/src/common/tonemap.c 2006/05/18 01:58:18 3.26 +++ ray/src/common/tonemap.c 2006/08/09 16:26:54 3.28 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tonemap.c,v 3.26 2006/05/18 01:58:18 greg Exp $"; +static const char RCSid[] = "$Id: tonemap.c,v 3.28 2006/08/09 16:26:54 greg Exp $"; #endif /* * Tone mapping functions. @@ -232,7 +232,6 @@ int len ) { static const char funcName[] = "tmCvGrays"; - double d; int i; if (tms == NULL) @@ -459,10 +458,12 @@ double gamval if (gamval < MINGAM) gamval = tms->mongam; d = log(expmult/tms->inpsf); - for (i = tms->mbrmax-tms->mbrmin+1; i--; ) - tms->lumap[i] = 256. * exp( + for (i = tms->mbrmax-tms->mbrmin+1; i--; ) { + double val = 256. * exp( ( d + (tms->mbrmin+i)*(1./TM_BRTSCALE) ) - / gamval ); + / gamval); + tms->lumap[i] = val >= (double)0xffff ? 0xffff : (int)val; + } returnOK; }