| 1 |
#ifndef CVD_LA_H |
| 2 |
#define CVD_LA_H |
| 3 |
|
| 4 |
#include <iostream> |
| 5 |
|
| 6 |
namespace CVD |
| 7 |
{ |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
template <typename T> |
| 17 |
class La |
| 18 |
{ |
| 19 |
public: |
| 20 |
|
| 21 |
La() { } |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
La(T l, T a) |
| 26 |
: luminance(l) |
| 27 |
, alpha(a) |
| 28 |
{ |
| 29 |
} |
| 30 |
|
| 31 |
T luminance; |
| 32 |
T alpha; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
La<T>& operator=(const La<T>& c) |
| 37 |
{ |
| 38 |
luminance = c.luminance; |
| 39 |
alpha = c.alpha; |
| 40 |
return *this; |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
template <typename T2> |
| 46 |
La<T>& operator=(const La<T2>& c) |
| 47 |
{ |
| 48 |
luminance = static_cast<T>(c.luminance); |
| 49 |
alpha = static_cast<T>(c.alpha); |
| 50 |
return *this; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
bool operator==(const La<T>& c) const |
| 56 |
{ |
| 57 |
return luminance == c.luminance && alpha == c.alpha; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
bool operator!=(const La<T>& c) const |
| 63 |
{ |
| 64 |
return luminance != c.luminance || alpha != c.alpha; |
| 65 |
} |
| 66 |
}; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
template <typename T> |
| 73 |
std::ostream& operator<<(std::ostream& os, const La<T>& x) |
| 74 |
{ |
| 75 |
return os << "(" << x.luminance << "," << x.alpha << ")"; |
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
inline std::ostream& operator<<(std::ostream& os, const La<unsigned char>& x) |
| 83 |
{ |
| 84 |
return os << "(" << static_cast<unsigned int>(x.luminance) << "," |
| 85 |
<< static_cast<unsigned int>(x.alpha) << ")"; |
| 86 |
} |
| 87 |
|
| 88 |
} |
| 89 |
#endif |