Little optimization for darken_image()
This commit is contained in:
parent
7f9d89ab39
commit
e4d8557f7c
1 changed files with 4 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue