00001
00002
00003 #ifndef colorizerH
00004 #define colorizerH
00005
00006 #include "surface.h"
00007
00008 class ColorSwitch
00009 {
00010
00011 class HSV
00012 {
00013 public:
00014 int h;
00015 int s;
00016 int v;
00017 HSV( int hh, int ss, int vv ) : h(hh), s(ss), v(vv) {};
00018 HSV() : h(0), s(0), v(0) {};
00019 };
00020
00021 struct Cache {
00022 DI_Color col[9][256][256];
00023 };
00024
00025 Cache* cache;
00026
00027 static const int playerAngles[9];
00028
00029 static const bool sat[9];
00030
00031 void generate();
00032
00033 HSV rgb2hsv( int r, int g);
00034 DI_Color hsv2rgb( HSV hsv);
00035
00036
00037 public:
00038 ColorSwitch();
00039
00040 inline DI_Color switchC( int player, int r, int g, int b) {
00041 if ( g == b && r > g) {
00042 if ( !cache )
00043 generate();
00044
00045 return cache->col[player][r][g];
00046 } else {
00047 return DI_Color(r,g,b);
00048 }
00049 }
00050 };
00051
00052 extern ColorSwitch colorSwitch;
00053
00054 #endif