Advanced Strategic Command
lighten.h
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2004 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 #ifndef lightenH
22  #define lightenH
23 
24 #include <cmath>
25  #include <map>
26  #include "loki/static_check.h"
27  #include "../libs/sdlmm/src/sdlmm.h"
28  #include "surface.h"
29 
30 #include "../misc.h"
31  #include "../palette.h"
32  // #include "../basegfx.h"
33 
34 extern Uint8 saturationTranslationTable[256][256];
35 
36 
37 inline SDLmm::Color lighten_Color( SDLmm::Color color, int factor16 )
38 {
39  return saturationTranslationTable[color & 0xff][factor16] |
40  (saturationTranslationTable[(color >> 8) & 0xff][factor16] << 8 ) |
41  (saturationTranslationTable[(color >> 16) & 0xff][factor16] << 16 ) |
42  (color & 0xff000000);
43 }
44 
45 inline void lighten_Color( SDLmm::Color* color, int factor16 )
46 {
47  *color = lighten_Color( *color, factor16 );
48 };
49 
50 inline SDL_Color lighten_Color( const SDL_Color& color, int factor16 )
51 {
52  SDL_Color c = color;
53  c.r = saturationTranslationTable[color.r & 0xff][factor16];
54  c.g = saturationTranslationTable[color.g & 0xff][factor16];
55  c.b = saturationTranslationTable[color.b & 0xff][factor16];
56  return c;
57 }
58 
59 #endif
60 
Uint8 saturationTranslationTable[256][256]
Definition: drawing.cpp:35
SDLmm::Color Color
Definition: blitter.h:35
SDLmm::Color lighten_Color(SDLmm::Color color, int factor16)
Definition: lighten.h:37