00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef CVD_INCLUDE_BGRX_H
00022 #define CVD_INCLUDE_BGRX_H
00023
00024 #include <iostream>
00025 #include <cvd/internal/is_pod.h>
00026
00027 namespace CVD {
00028
00029
00031
00036 template <typename T>
00037 class Bgrx
00038 {
00039 public:
00041 Bgrx() {}
00046 Bgrx(T b, T g, T r) : blue(b), green(g), red(r) {}
00047
00048 T blue;
00049 T green;
00050 T red;
00051 T dummy;
00052
00055 template <typename T2>
00056 Bgrx<T>& operator=(const Bgrx<T2>& c){
00057 blue = static_cast<T>(c.blue);
00058 green = static_cast<T>(c.green);
00059 red = static_cast<T>(c.red);
00060 return *this;
00061 }
00062
00065 bool operator==(const Bgrx<T>& c) const
00066 {return red == c.red && green == c.green && blue == c.blue;}
00067
00070 bool operator!=(const Bgrx<T>& c) const
00071 {return red != c.red || green != c.green || blue != c.blue;}
00072
00073
00074 };
00075
00080 template <typename T>
00081 std::ostream& operator <<(std::ostream& os, const Bgrx<T>& x)
00082 {
00083 return os << "(" << x.blue << ","
00084 << x.green << "," << x.red << ")";
00085 }
00086
00091 inline std::ostream& operator <<(std::ostream& os, const Bgrx<unsigned char>& x)
00092 {
00093 return os << "("
00094 << static_cast<unsigned int>(x.blue) << ")"
00095 << static_cast<unsigned int>(x.green) << ","
00096 << static_cast<unsigned int>(x.red) << ",";
00097 }
00098
00099 #ifndef DOXYGEN_IGNORE_INTERNAL
00100 namespace Internal
00101 {
00102 template<class C> struct is_POD<Bgrx<C> >
00103 {
00104 enum { is_pod = is_POD<C>::is_pod };
00105 };
00106 }
00107 #endif
00108
00109
00110
00111 }
00112 #endif
00113