1 #ifndef CVD_RGB_TRAITS_H 2 #define CVD_RGB_TRAITS_H 6 #include <cvd/internal/builtin_components.h> 7 #include <cvd/internal/pixel_traits.h> 22 static const size_t count = 3;
25 static const P&
get(
const Rgb<P>& pixel,
size_t i)
27 return *(
reinterpret_cast<const P*
>(&pixel) + i);
31 static P&
get(
Rgb<P>& pixel,
size_t i)
33 return *(
reinterpret_cast<P*
>(&pixel) + i);
42 static const size_t count = 3;
45 static const P&
get(
const Bgrx<P>& pixel,
size_t i)
47 return *(
reinterpret_cast<const P*
>(&pixel) + i);
51 static P&
get(
Bgrx<P>& pixel,
size_t i)
53 return *(
reinterpret_cast<P*
>(&pixel) + i);
61 typedef unsigned char type;
62 static const size_t count = 3;
64 static const type&
get(
const Rgb8& pixel,
size_t i)
66 return *(
reinterpret_cast<const unsigned char*
>(&pixel) + i);
70 static type&
get(
Rgb8& pixel,
size_t i)
72 return *(
reinterpret_cast<unsigned char*
>(&pixel) + i);
81 static const size_t count = 4;
83 static const P&
get(
const Rgba<P>& pixel,
size_t i)
85 return *(
reinterpret_cast<const P*
>(&pixel) + i);
89 static P&
get(
Rgba<P>& pixel,
size_t i)
91 return *(
reinterpret_cast<P*
>(&pixel) + i);
100 static const size_t count = 2;
102 static const P&
get(
const La<P>& pixel,
size_t i)
104 return *(
reinterpret_cast<const P*
>(&pixel) + i);
107 static P&
get(
La<P>& pixel,
size_t i)
109 return *(
reinterpret_cast<P*
>(&pixel) + i);
117 static const size_t count = 4;
119 static const P&
get(
const Argb<P>& pixel,
size_t i)
122 return i == 0 ? pixel.
red : (i == 1 ? pixel.green : (i == 2 ? pixel.blue : pixel.alpha));
125 static P&
get(
Argb<P>& pixel,
size_t i)
128 return i == 0 ? pixel.red : (i == 1 ? pixel.green : (i == 2 ? pixel.blue : pixel.alpha));
173 template <
class T,
int LIFT>
180 template <
class T,
int LIFT>
187 template <
class T,
int LIFT>
206 static inline T sum(
const T& a,
const S& b) {
return T(a.red + b.red, a.green + b.green, a.blue + b.blue); }
208 static inline void add(T& a,
const S& b)
215 static inline T diff(
const T& a,
const S& b) {
return T(a.red - b.red, a.green - b.green, a.blue - b.blue); }
217 static inline void sub(T& a,
const S& b)
224 static inline T prod(
const T& a,
const S& b) {
return T(a.red * b, a.green * b, a.blue * b); }
226 static inline void mul(T& a,
const S& b)
233 static inline T quot(
const T& a,
const S& b) {
return T(a.red / b, a.green / b, a.blue / b); }
235 static inline void div(T& a,
const S& b)
242 static inline void assign(T& a,
const S& b)
250 template <
class T,
class S>
252 template <
class T,
class S>
258 template <
class T,
class S>
260 template <
class T,
class S>
266 template <
class T,
class S>
268 template <
class T,
class S>
270 template <
class T,
class S>
276 template <
class T,
class S>
278 template <
class T,
class S>
280 template <
class T,
class S>
291 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); }
293 static inline void add(T& a,
const S& b)
301 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); }
303 static inline void sub(T& a,
const S& b)
311 static inline T prod(
const T& a,
const S& b) {
return T(a.red * b, a.green * b, a.blue * b, a.alpha * b); }
313 static inline void mul(T& a,
const S& b)
321 static inline T quot(
const T& a,
const S& b) {
return T(a.red / b, a.green / b, a.blue / b, a.alpha / b); }
323 static inline void div(T& a,
const S& b)
331 static inline void assign(T& a,
const S& b)
340 template <
class T,
class S>
342 template <
class T,
class S>
348 template <
class T,
class S>
350 template <
class T,
class S>
356 template <
class T,
class S>
358 template <
class T,
class S>
360 template <
class T,
class S>
366 template <
class T,
class S>
368 template <
class T,
class S>
370 template <
class T,
class S>
381 static inline T sum(
const T& a,
const S& b) {
return T(a.luminance + b.luminance, a.alpha + b.alpha); }
383 static inline void add(T& a,
const S& b)
385 a.luminance += b.luminance;
389 static inline T diff(
const T& a,
const S& b) {
return T(a.luminance - b.luminance, a.alpha - b.alpha); }
391 static inline void sub(T& a,
const S& b)
393 a.luminance -= b.luminance;
397 static inline T prod(
const T& a,
const S& b) {
return T(a.luminance * b, a.alpha * b); }
399 static inline void mul(T& a,
const S& b)
405 static inline T quot(
const T& a,
const S& b) {
return T(a.luminance / b, a.alpha / b); }
407 static inline void div(T& a,
const S& b)
413 static inline void assign(T& a,
const S& b)
415 a.luminance = b.luminance;
420 template <
class T,
class S>
422 template <
class T,
class S>
428 template <
class T,
class S>
430 template <
class T,
class S>
436 template <
class T,
class S>
438 template <
class T,
class S>
440 template <
class T,
class S>
441 inline La<T>& operator*=(
La<T>& a,
const S& b)
446 template <
class T,
class S>
448 template <
class T,
class S>
450 template <
class T,
class S>
451 inline La<T>& operator/=(
La<T>& a,
const S& b)
A colour consisting of red, green and blue components.
Definition: rgb.h:25
Definition: rgb_components.h:288
All classes and functions are within the CVD namespace.
Definition: argb.h:6
A colour consisting of red, green, blue and dummy components, in the order bgr dummy in memory...
Definition: bgrx.h:16
A colour consisting of red, green, blue and alpha components.
Definition: argb.h:17
A colour consisting of luminance and alpha components.
Definition: la.h:17
Definition: rgb_components.h:203
Definition: rgb_components.h:378
A 32-bit colour.
Definition: rgb8.h:11
A colour consisting of red, green, blue and alpha components.
Definition: rgba.h:17
T red
The red component.
Definition: argb.h:44
Definition: builtin_components.h:38
Definition: pixel_traits.h:16
Definition: rgb_components.h:133