00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef COLOR_RANGE_H_INCLUDED
00019 #define COLOR_RANGE_H_INCLUDED
00020
00021
00022 #ifdef _MSC_VER
00023 #undef max
00024 #undef min
00025 #endif
00026
00027 #include "global.hpp"
00028 #include <map>
00029 #include <string>
00030 #include <vector>
00031
00032 #include "SDL_types.h"
00033
00034
00035 std::vector<Uint32> string2rgb(std::string s);
00036
00037 class color_range
00038 {
00039 public:
00040 color_range(Uint32 mid , Uint32 max = 0x00FFFFFF , Uint32 min = 0x00000000 , Uint32 rep = 0x00808080):mid_(mid),max_(max),min_(min),rep_(rep){};
00041 color_range(const std::vector<Uint32>& v)
00042 : mid_(v.size() ? v[0] : 0x00808080),
00043 max_(v.size() > 1 ? v[1] : 0x00FFFFFF),
00044 min_(v.size() > 2 ? v[2] : 0x00000000),
00045 rep_(v.size() > 3 ? v[3] : mid_)
00046 {
00047 };
00048 color_range() : mid_(0x00808080), max_(0x00FFFFFF), min_(0x00000000), rep_(0x00808080) {};
00049 Uint32 mid() const{return(mid_);};
00050 Uint32 max() const{return(max_);};
00051 Uint32 min() const{return(min_);};
00052
00053 Uint32 rep() const{return(rep_);};
00054 bool operator<(const color_range& b) const
00055 {
00056 if(mid_ != b.mid()) return(mid_ < b.mid());
00057 if(max_ != b.max()) return(max_ < b.max());
00058 if(min_ != b.min()) return(min_ < b.min());
00059 return(rep_ < b.rep());
00060 }
00061 bool operator==(const color_range& b) const
00062 {
00063 return(mid_ == b.mid() && max_ == b.max() && min_ == b.min() && rep_ == b.rep());
00064 }
00065 int index() const;
00066 private:
00067 Uint32 mid_ , max_ , min_ , rep_;
00068 };
00069
00070 std::vector<Uint32> palette(color_range cr);
00071 std::map<Uint32, Uint32> recolor_range(const color_range& new_rgb, const std::vector<Uint32>& old_rgb);
00072 std::string rgb2highlight(Uint32 rgb);
00073 #endif