DATAKIT SDK  V2026.4
dtk_rgb.hpp
Go to the documentation of this file.
1 #ifndef __DTK_RGB_HPP__
2 #define __DTK_RGB_HPP__
3 #include <fstream>
4 #include "def/define.h"
5 #include "dtk/config.hpp"
6 
7 class Dtk_RGB
8 {
9 private:
10  int _RGBA[5];
11  //void init();
12  void reset();
13  //Dtk_bool compare(Dtk_RGB) const;
14  //void copy(const Dtk_RGB& s);
15 public:
17  Dtk_RGB(const Dtk_RGB& s);
19  Dtk_RGB(int r, int g, int b, int a = -1, int inIndexReader = -1 );
20  Dtk_RGB(int (&rgba)[5]);
21  Dtk_RGB(int (&rgba)[4]);
22  Dtk_RGB(int (&rgb)[3]);
23  void Clear() { reset(); }
25 
27  int& operator [](int pos);
28  const int& operator [](int pos) const;
29 
30  inline bool HasColor() const { return _RGBA[0] >= 0;}
31 
32  inline bool HasAlpha() const { return _RGBA[3] >= 0;}
33 
34  inline bool IsFilled() const { return (_RGBA[0] >= 0 || _RGBA[3] >= 0);}
35 
36  inline int & R() {return _RGBA[0];}
37  inline const int & R() const {return _RGBA[0];}
38 
39  inline int & G() {return _RGBA[1];}
40  inline const int & G() const {return _RGBA[1];}
41 
42  inline int & B() {return _RGBA[2];}
43  inline const int & B() const {return _RGBA[2];}
44 
45  inline int & A() {return _RGBA[3];}
46  inline const int & A() const {return _RGBA[3];}
47 
48  inline int & IndexReader() {return _RGBA[4];}
49  inline const int & IndexReader() const {return _RGBA[4];}
50 
51  inline void SetRGBA(const int& inRed, const int& inGreen, const int& inBlue, const int& inAlpha = -1)
52  {
53  _RGBA[0] = inRed;
54  _RGBA[1] = inGreen;
55  _RGBA[2] = inBlue;
56  _RGBA[3] = inAlpha;
57  }
58 
59  inline void GetRGB(int& outRed, int& outGreen, int& outBlue)
60  {
61  outRed = _RGBA[0];
62  outGreen = _RGBA[1];
63  outBlue = _RGBA[2];
64  }
65  inline void GetRGBA(int& outRed, int& outGreen, int& outBlue, int& outAlpha)
66  {
67  GetRGB(outRed, outGreen, outBlue);
68  outAlpha = _RGBA[3];
69  }
70 
71  friend bool operator==(const Dtk_RGB & lhs, const Dtk_RGB & rhs);
72 
73  friend bool operator<(const Dtk_RGB & lhs, const Dtk_RGB & rhs);
74 
75  friend bool operator!=(const Dtk_RGB & lhs, const Dtk_RGB & rhs);
76 
77  friend bool operator>(const Dtk_RGB & lhs, const Dtk_RGB & rhs);
78 
79  friend bool operator<=(const Dtk_RGB & lhs, const Dtk_RGB & rhs);
80 
81  friend bool operator>=(const Dtk_RGB & lhs, const Dtk_RGB & rhs);
82 };
83 
84 
85 #endif
Dtk_RGB::G
int & G()
Definition: dtk_rgb.hpp:39
Dtk_RGB::operator>=
friend bool operator>=(const Dtk_RGB &lhs, const Dtk_RGB &rhs)
Dtk_RGB::Dtk_RGB
Dtk_RGB(int(&rgba)[5])
Dtk_RGB::G
const int & G() const
Definition: dtk_rgb.hpp:40
Dtk_RGB::Dtk_RGB
Dtk_RGB(int(&rgb)[3])
Dtk_RGB::R
int & R()
Definition: dtk_rgb.hpp:36
Dtk_RGB::SetRGBA
void SetRGBA(const int &inRed, const int &inGreen, const int &inBlue, const int &inAlpha=-1)
Definition: dtk_rgb.hpp:51
Dtk_RGB::Dtk_RGB
Dtk_RGB(Dtk_RGB &&s) DTK_NOEXCEPT
Dtk_RGB::operator>
friend bool operator>(const Dtk_RGB &lhs, const Dtk_RGB &rhs)
config.hpp
Dtk_RGB::GetRGB
void GetRGB(int &outRed, int &outGreen, int &outBlue)
Definition: dtk_rgb.hpp:59
Dtk_RGB::IndexReader
int & IndexReader()
Definition: dtk_rgb.hpp:48
Dtk_RGB::operator=
Dtk_RGB & operator=(const Dtk_RGB &s)
Dtk_RGB::operator<
friend bool operator<(const Dtk_RGB &lhs, const Dtk_RGB &rhs)
Dtk_RGB::B
const int & B() const
Definition: dtk_rgb.hpp:43
Dtk_RGB::operator<=
friend bool operator<=(const Dtk_RGB &lhs, const Dtk_RGB &rhs)
Dtk_RGB::A
int & A()
Definition: dtk_rgb.hpp:45
Dtk_RGB::operator==
friend bool operator==(const Dtk_RGB &lhs, const Dtk_RGB &rhs)
Dtk_RGB::Dtk_RGB
Dtk_RGB(int r, int g, int b, int a=-1, int inIndexReader=-1)
Dtk_RGB::HasAlpha
bool HasAlpha() const
Definition: dtk_rgb.hpp:32
Dtk_RGB::operator!=
friend bool operator!=(const Dtk_RGB &lhs, const Dtk_RGB &rhs)
Dtk_RGB::IsFilled
bool IsFilled() const
Definition: dtk_rgb.hpp:34
Dtk_RGB::B
int & B()
Definition: dtk_rgb.hpp:42
define.h
Dtk_RGB::Dtk_RGB
Dtk_RGB(const Dtk_RGB &s)
Dtk_RGB::Dtk_RGB
Dtk_RGB()
Dtk_RGB::~Dtk_RGB
~Dtk_RGB()
Dtk_RGB::IndexReader
const int & IndexReader() const
Definition: dtk_rgb.hpp:49
Dtk_RGB::operator[]
int & operator[](int pos)
Dtk_RGB::Clear
void Clear()
Definition: dtk_rgb.hpp:23
Dtk_RGB::Dtk_RGB
Dtk_RGB(int(&rgba)[4])
Dtk_RGB::GetRGBA
void GetRGBA(int &outRed, int &outGreen, int &outBlue, int &outAlpha)
Definition: dtk_rgb.hpp:65
Dtk_RGB::HasColor
bool HasColor() const
Definition: dtk_rgb.hpp:30
Dtk_RGB
Definition: dtk_rgb.hpp:8
Dtk_RGB::A
const int & A() const
Definition: dtk_rgb.hpp:46
Dtk_RGB::R
const int & R() const
Definition: dtk_rgb.hpp:37
DTK_NOEXCEPT
#define DTK_NOEXCEPT
Definition: config.hpp:20