Ignore:
Timestamp:
Apr 25, 2001, 8:55:35 PM (24 years ago)
Author:
umoeller
Message:

Misc. fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/gpih.c

    r56 r63  
    196196
    197197/*
     198 * HackColor:
     199 *
     200 */
     201
     202VOID HackColor(PBYTE pb, double dFactor)
     203{
     204    ULONG ul = (ULONG)((double)(*pb) * dFactor);
     205    if (ul > 255)
     206        *pb = 255;
     207    else
     208        *pb = (BYTE)ul;
     209}
     210
     211/*
    198212 *@@ gpihManipulateRGB:
    199213 *      this changes an RGB color value
    200214 *      by multiplying each color component
    201  *      (red, green, blue) with bMultiplier
    202  *      and dividing it by bDivisor afterwards.
     215 *      (red, green, blue) with dFactor.
    203216 *
    204217 *      Each color component is treated separately,
    205  *      so if overflows occur (because bMultiplier
     218 *      so if overflows occur (because dFactor
    206219 *      is > 1), this does not affect the other
    207220 *      components.
    208221 *
    209  *      Example: if you pass a brigt red
    210  *      (0xFF0000) to this func, this will
    211  *      be 0x7F0000 if bMultiplier and
    212  *      bDivisor are 1 and 2.
     222 *@@changed V0.9.11 (2001-04-25) [umoeller]: changed prototype to use a double now
    213223 */
    214224
    215225VOID gpihManipulateRGB(PLONG plColor,       // in/out: RGB color
    216                        BYTE bMultiplier,    // in: multiplier
    217                        BYTE bDivisor)       // in: divisor
     226                       double dFactor)      // in: factor (> 1 makes brigher, < 1 makes darker)
    218227{
    219228    PBYTE   pb = (PBYTE)plColor;
     229
    220230    // in memory, the bytes are blue, green, red, unused
    221     *pb++ = (BYTE)((LONG)(*pb) * bMultiplier / bDivisor); // blue
    222     *pb++ = (BYTE)((LONG)(*pb) * bMultiplier / bDivisor); // green
    223     *pb++ = (BYTE)((LONG)(*pb) * bMultiplier / bDivisor); // red
     231
     232    // blue
     233    ULONG   ul = (ULONG)(   (double)(*pb) * dFactor
     234                        );
     235    if (ul > 255)
     236        *pb = 255;
     237    else
     238        *pb = (BYTE)ul;
     239
     240    // green
     241    ul = (ULONG)(   (double)(*(++pb)) * dFactor
     242                );
     243    if (ul > 255)
     244        *pb = 255;
     245    else
     246        *pb = (BYTE)ul;
     247
     248    // red
     249    ul = (ULONG)(   (double)(*(++pb)) * dFactor
     250                );
     251    if (ul > 255)
     252        *pb = 255;
     253    else
     254        *pb = (BYTE)ul;
    224255}
    225256
Note: See TracChangeset for help on using the changeset viewer.