Mail Archives: djgpp/1997/03/05/19:07:10
> > If you want to tint the sprites to some color other than black, pass a
> > color other than "0, 0, 0" to the create_light_table() routine, eg.
> > "255, 255, 255" to tint the images to white. If you want to tint them in
> > both directions, you could (a bit more work) use the
> > create_color_table() function to build a lookup table which will treat
> > light level 128 as the original color, 0 as black, and 255 as white.
> When I read this, I started thinking how this would be achieved (the lookup
> table to treat light level 128 as the original colour, 0 as black, and 255
> as white). But I can't think of how it would be done. Any tips?
Well, for true colour stuff I use this sort of setup...
char *brightness = (char *)malloc(256 * 256));
for (i = 0; i < 256; i++)
for (j = 0; j < 256; j++)
{
val = (i / 128) * j;
brightness[i][j] = (unsigned char) val;
}
You get the point.... :) You should make sure you do correct int/float
conversions etc, but otherwise, this is extremely effective for me...
Leathal.
- Raw text -