21 #ifndef CVD_RGB_TRAITS_H
22 #define CVD_RGB_TRAITS_H
43 static const P&
get(
const Rgb<P>& pixel,
size_t i)
45 return *(
reinterpret_cast<const P*
>(&pixel)+i);
49 static P&
get(
Rgb<P>& pixel,
size_t i)
51 return *(
reinterpret_cast<P*
>(&pixel)+i);
60 typedef unsigned char type;
63 static const type&
get(
const Rgb8& pixel,
size_t i)
65 return *(
reinterpret_cast<const unsigned char*
>(&pixel)+i);
69 static type&
get(
Rgb8& pixel,
size_t i)
71 return *(
reinterpret_cast<unsigned char*
>(&pixel)+i);
81 static const P&
get(
const Rgba<P>& pixel,
size_t i)
83 return *(
reinterpret_cast<const P*
>(&pixel)+i);
89 return *(
reinterpret_cast<P*
>(&pixel)+i);
99 static const P&
get(
const La<P>& pixel,
size_t i)
101 return *(
reinterpret_cast<const P*
>(&pixel)+i);
104 static P&
get(
La<P>& pixel,
size_t i)
106 return *(
reinterpret_cast<P*
>(&pixel)+i);
128 template<
class T,
int LIFT>
struct traits<
La<T>, LIFT>
142 template <
class S>
static inline T
sum(
const T& a,
const S& b) {
return T(a.red+b.red, a.green+b.green, a.blue+b.blue); }
143 template <
class S>
static inline void add(T& a,
const S& b) { a.red+=b.red; a.green+=b.green; a.blue+=b.blue; }
144 template <
class S>
static inline T
diff(
const T& a,
const S& b) {
return T(a.red-b.red, a.green-b.green, a.blue-b.blue); }
145 template <
class S>
static inline void sub(T& a,
const S& b) { a.red-=b.red; a.green-=b.green; a.blue-=b.blue; }
146 template <
class S>
static inline T
prod(
const T& a,
const S& b) {
return T(a.red*b, a.green*b, a.blue*b); }
147 template <
class S>
static inline void mul(T& a,
const S& b) { a.red*=b; a.green*=b; a.blue*=b; }
148 template <
class S>
static inline T
quot(
const T& a,
const S& b) {
return T(a.red/b, a.green/b, a.blue/b); }
149 template <
class S>
static inline void div(T& a,
const S& b) { a.red/=b; a.green/=b; a.blue/=b; }
150 template <
class S>
static inline void assign(T& a,
const S& b) { a.red=b.red; a.green=b.green; a.blue=b.blue; }
166 template <
class S>
static inline T
sum(
const T& a,
const S& b) {
return T(a.red+b.red, a.green+b.green, a.blue+b.blue, a.alpha+b.alpha); }
167 template <
class S>
static inline void add(T& a,
const S& b) { a.red+=b.red; a.green+=b.green; a.blue+=b.blue; a.alpha+=b.alpha;}
168 template <
class S>
static inline T
diff(
const T& a,
const S& b) {
return T(a.red-b.red, a.green-b.green, a.blue-b.blue, a.alpha-b.alpha); }
169 template <
class S>
static inline void sub(T& a,
const S& b) { a.red-=b.red; a.green-=b.green; a.blue-=b.blue; a.alpha-=b.alpha; }
170 template <
class S>
static inline T
prod(
const T& a,
const S& b) {
return T(a.red*b, a.green*b, a.blue*b, a.alpha*b); }
171 template <
class S>
static inline void mul(T& a,
const S& b) { a.red*=b; a.green*=b; a.blue*=b; a.alpha*=b; }
172 template <
class S>
static inline T
quot(
const T& a,
const S& b) {
return T(a.red/b, a.green/b, a.blue/b, a.alpha/b); }
173 template <
class S>
static inline void div(T& a,
const S& b) { a.red/=b; a.green/=b; a.blue/=b; a.alpha/=b;}
174 template <
class S>
static inline void assign(T& a,
const S& b) { a.red=b.red; a.green=b.green; a.blue=b.blue; a.alpha=b.alpha; }
189 template <
class S>
static inline T
sum(
const T& a,
const S& b) {
return T(a.luminance+b.luminance, a.alpha+b.alpha); }
190 template <
class S>
static inline void add(T& a,
const S& b) { a.luminance+=b.luminance; a.alpha+=b.alpha;}
191 template <
class S>
static inline T
diff(
const T& a,
const S& b) {
return T(a.luminance-b.luminance, a.alpha-b.alpha); }
192 template <
class S>
static inline void sub(T& a,
const S& b) { a.luminance-=b.luminance; a.alpha-=b.alpha; }
193 template <
class S>
static inline T
prod(
const T& a,
const S& b) {
return T(a.luminance*b, a.alpha*b); }
194 template <
class S>
static inline void mul(T& a,
const S& b) { a.luminance*=b; a.alpha*=b; }
195 template <
class S>
static inline T
quot(
const T& a,
const S& b) {
return T(a.luminance/b, a.alpha/b); }
196 template <
class S>
static inline void div(T& a,
const S& b) { a.luminance/=b; a.alpha/=b;}
197 template <
class S>
static inline void assign(T& a,
const S& b) { a.luminance=b.luminance; a.alpha=b.alpha; }
static T diff(const T &a, const S &b)
La< typename Pixel::traits< T >::wider_type > wider_type
static void div(T &a, const S &b)
Rgba< typename Pixel::traits< T >::wider_type > wider_type
static const size_t count
static T quot(const T &a, const S &b)
static void add(T &a, const S &b)
Rgba< typename Pixel::traits< T >::float_type > float_type
static T diff(const T &a, const S &b)
static T prod(const T &a, const S &b)
static void add(T &a, const S &b)
static void mul(T &a, const S &b)
static T sum(const T &a, const S &b)
Rgb< T > operator/(const Rgb< T > &a, const S &b)
static void div(T &a, const S &b)
static T quot(const T &a, const S &b)
static void assign(T &a, const S &b)
Rgb< typename Pixel::traits< T >::wider_type > wider_type
Rgb< T > operator+(const Rgb< T > &a, const Rgb< S > &b)
static T prod(const T &a, const S &b)
Rgb< T > operator-(const Rgb< T > &a, const Rgb< S > &b)
static void sub(T &a, const S &b)
static T diff(const T &a, const S &b)
static T quot(const T &a, const S &b)
static void mul(T &a, const S &b)
ImageRef operator*(const int scale, const ImageRef &ref)
Rgb< T > & operator-=(Rgb< T > &a, const Rgb< S > &b)
static T prod(const T &a, const S &b)
Rgb< T > & operator/=(Rgb< T > &a, const S &b)
static void add(T &a, const S &b)
Rgb< typename Pixel::traits< T >::float_type > float_type
static T sum(const T &a, const S &b)
Rgb< T > & operator+=(Rgb< T > &a, const Rgb< S > &b)
static void mul(T &a, const S &b)
static void sub(T &a, const S &b)
La< typename Pixel::traits< T >::float_type > float_type
static T sum(const T &a, const S &b)
static void div(T &a, const S &b)
static void assign(T &a, const S &b)
static void sub(T &a, const S &b)
Rgb< T > & operator*=(Rgb< T > &a, const S &b)
static void assign(T &a, const S &b)