Little optimization for darken_image()

This commit is contained in:
Benoît Timbert 2005-12-13 16:57:27 +00:00
parent 7f9d89ab39
commit e4d8557f7c

View file

@ -350,9 +350,10 @@ surface darken_image(surface const &surf)
const Uint8 avg = (Uint8)((77*(Uint16)red +
150*(Uint16)green +
29*(Uint16)blue) / 256);
const Uint8 r=(Uint8)(avg*.77);
const Uint8 g=(Uint8)(avg*.67);
const Uint8 b=(Uint8)(avg*.72);
// then tint 77%, 67%, 72%
const Uint8 r=(Uint8)((avg*196)>>8);
const Uint8 g=(Uint8)((avg*171)>>8);
const Uint8 b=(Uint8)((avg*184)>>8);
*beg = SDL_MapRGBA(nsurf->format,r,g,b,alpha);