--- rxvt-unicode/src/rxvttoolkit.C 2006/02/19 16:55:03 1.55 +++ rxvt-unicode/src/rxvttoolkit.C 2006/07/05 19:22:15 1.58 @@ -1,9 +1,9 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: rxvttoolkit.C *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. - * Copyright (c) 2003-2004 Marc Lehmann + * Copyright (c) 2003-2006 Marc Lehmann * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -651,6 +651,13 @@ refcache displays; ///////////////////////////////////////////////////////////////////////////// +// + +static unsigned int +insert_component (unsigned int value, unsigned int mask, unsigned int shift) +{ + return (value * (mask + 1) >> 16) << shift; +} bool rxvt_color::alloc (rxvt_screen *screen, const rgba &color) @@ -670,10 +677,10 @@ c.color.blue = color.b; c.color.alpha = color.a; - c.pixel = ((color.r * format->direct.redMask / rgba::MAX_CC) << format->direct.red ) - | ((color.g * format->direct.greenMask / rgba::MAX_CC) << format->direct.green) - | ((color.b * format->direct.blueMask / rgba::MAX_CC) << format->direct.blue ) - | ((color.a * format->direct.alphaMask / rgba::MAX_CC) << format->direct.alpha); + c.pixel = insert_component (color.r, format->direct.redMask , format->direct.red ) + | insert_component (color.g, format->direct.greenMask, format->direct.green) + | insert_component (color.b, format->direct.blueMask , format->direct.blue ) + | insert_component (color.a, format->direct.alphaMask, format->direct.alpha); return true; }