[AD] New function idea

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


This function can scale a 32-bit color, it's simple if it's not already
in allegro could help out a bit.

Of course GCC does terribly at optimizing this, so an ASM copy would be
better.  (GCC does 32x32->64 multiplies when simple 8x8->16 will do).

You can call it as pixelshade(&mycol, &mycol, 128) where mycol is an
integer and 128 represents 50%.

void pixelshade(unsigned char *in, unsigned char *dest, unsigned level)
{
    dest[0] = (in[0]*level)>>8;
    dest[1] = (in[1]*level)>>8;
    dest[2] = (in[2]*level)>>8;
    dest[3] = (in[3]*level)>>8;
}


__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/