Mail Archives: djgpp/1997/06/26/08:16:43
Alex Kain writes:
>How do I use the function to fade a colored pixel to its closest
>grayscale color in a palette?
a) There is no such function as 'Create_Color_Table'.
b) If you are talking about create_color_table(), try something like;
RGB myblender(PALLETE pal, int x, int y)
{
RGB c;
int grayscale = ((int)pal[y].r + (int)pal[y].g + (int)pal[y].b) / 3;
c.r = (greyscale * (255 - x) / 255) + ((int)pal[y].r * x / 255);
c.g = (greyscale * (255 - x) / 255) + ((int)pal[y].g * x / 255);
c.b = (greyscale * (255 - x) / 255) + ((int)pal[y].b * x / 255);
return c;
}
color_map = malloc(sizeof(COLOR_MAP));
create_color_table(color_map, palette, myblender, NULL);
Then you can use draw_lit_sprite(), draw_lit_rle_sprite(), and the lit
texture mapping modes, and a light level of 0 will give you a grayscale
(assuming there are suitable colors available in your palette, of
course!) while light 255 will give you the original colors.
This is untested, but it should work...)
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -