home *** CD-ROM | disk | FTP | other *** search
- #ifndef __COLOR_H__
- #define __COLOR_H__
-
- class Color // ╤Φδⁿφα ταΓΦ±Φ∞ε≥ⁿ ε≥ ∩δα≥⌠ε≡∞√ - ∩≡εΓσ≡Φ≥ⁿ ∩≡Φ ∩σ≡σ⌡εΣσ φα Σ≡≤π≤■
- {
- class Table
- {
- unsigned char data[256][256];
- public:
- Table();
- unsigned const char * row(unsigned char alpha)const
- {
- return data[alpha];
- }
- };
- static const Table alpha_table;
- public:
- Color()
- : r(0), g(0), b(0), a(0)
- {}
- Color(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
- : r(r), g(g), b(b), a(a)
- {}
-
- union
- {
- struct
- {
- unsigned char b,g,r,a;
- };
- unsigned pack;
- };
-
- bool operator==(const Color & v)const
- {
- return pack == v.pack;
- }
-
- bool operator!=(const Color & v)const
- {
- return pack != v.pack;
- }
-
- const Color & operator+= (const Color & v)
- {
- pack += v.pack;
- return *this;
- }
-
- void bilinear(const Color & src,unsigned char alpha)
- {
- const unsigned char * row_src = alpha_table.row( alpha );
- const unsigned char * row = alpha_table.row( 255 - alpha );
-
- r = row_src[src.r] + row[r];
- g = row_src[src.g] + row[g];
- b = row_src[src.b] + row[b];
- // a = row_src[src.a] + row[a]; ┬√ΩΦφ≤≥ε ≡αΣΦ ±Ωε≡ε±≥Φ
- }
- };
-
- inline Color operator+ (const Color & v1,const Color & v2)
- {
- Color c( v1 );
- c += v2;
- return c;
- }
-
- #endif //__COLOR_H__