From 258031e6b3ea12c7c56cdab0cc05d0d88670b464 Mon Sep 17 00:00:00 2001 From: wkendrick Date: Tue, 26 Jul 2011 20:46:21 +0000 Subject: Oh yeah, we already have sRGB<->linear conversions, currently used by some Magic tools. Now using it instead of ceil(pow()) and pow() for gamma-correction in thumbnail2(). (As they're look-ups, they're faster, too!) Thanks for the reminder, Albert C.! --- diff --git a/src/tuxpaint.c b/src/tuxpaint.c index 07cb425..2a11a23 100644 --- a/src/tuxpaint.c +++ b/src/tuxpaint.c @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA (See COPYING.txt) - June 14, 2002 - July 25, 2011 + June 14, 2002 - July 26, 2011 */ @@ -9234,9 +9234,12 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, src->format, &r, &g, &b, &a); #ifdef GAMMA_CORRECTED_THUMBNAILS - tr = tr + pow((float)r, gamma); - tb = tb + pow((float)b, gamma); - tg = tg + pow((float)g, gamma); +// tr = tr + pow((float)r, gamma); +// tb = tb + pow((float)b, gamma); +// tg = tg + pow((float)g, gamma); + tr = tr + sRGB_to_linear_table[r]; + tg = tg + sRGB_to_linear_table[g]; + tb = tb + sRGB_to_linear_table[b]; #else tr = tr + r; tb = tb + b; @@ -9256,9 +9259,12 @@ static SDL_Surface *thumbnail2(SDL_Surface * src, int max_x, int max_y, ta = ta / tmp; #ifdef GAMMA_CORRECTED_THUMBNAILS - tr = ceil(pow(tr, gamma_invert)); - tg = ceil(pow(tg, gamma_invert)); - tb = ceil(pow(tb, gamma_invert)); +// tr = ceil(pow(tr, gamma_invert)); +// tg = ceil(pow(tg, gamma_invert)); +// tb = ceil(pow(tb, gamma_invert)); + tr = linear_to_sRGB(tr); + tg = linear_to_sRGB(tg); + tb = linear_to_sRGB(tb); #endif if (keep_alpha == 0 && s->format->Amask != 0) -- cgit v0.9.1