aboutsummaryrefslogtreecommitdiffstats
path: root/meowpp/colors/YUV.h
blob: b3744d12a95d70375be3fe2603e59f4a3c496b6d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef   YUV_H_
#define   YUV_H_

#include "RGB.h"

namespace meow{
  template<class T>
  class YUV{
    protected:
      T yuv_[3];
      YUV();
      YUV(T const& y, T const& u, T const& v);
      YUV(T const* yuv);
    public:
      virtual ~YUV() { }
      ///////////////// **# not force #** ////////////////
      virtual T yMax() const = 0;
      virtual T yMin() const = 0;
      virtual T uMax() const = 0;
      virtual T uMin() const = 0;
      virtual T vMax() const = 0;
      virtual T vMin() const = 0;
      /////////////////// **# access #** /////////////////
      T y()           const;
      T u()           const;
      T v()           const;
      T yuv(size_t i) const;
      T vuy(size_t i) const;
      /////////////////// **# setting #** ////////////////
      T y(T const& val);
      T u(T const& val);
      T v(T const& val);
      T yuv(size_t i, T const& val);
      T vuy(size_t i, T const& val);
  };

  class YUVf: public YUV<double>{
    public:
      YUVf();
      ~YUVf();
      YUVf(double const& y, double const& u, double const& v);
      YUVf(double const* yuv);
      double yMin() const;
      double yMax() const;
      double uMin() const;
      double uMax() const;
      double vMin() const;
      double vMax() const;
  };

  template<class RGB_T, class YUV_T>
  inline void RGB_to_YUV(RGB<RGB_T> const& rgb, YUV<YUV_T>* yuv);
  template<class YUV_T, class RGB_T>
  inline void YUV_to_RGB(YUV<YUV_T> const& yuv, RGB<RGB_T>* rgb);
}

#include "YUV.hpp"

#endif // YUV_H_