MRPT  1.9.9
TColor.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "img-precomp.h" // Precompiled headers
11 
12 #include <mrpt/img/TColor.h>
14 #include <mrpt/system/os.h>
15 
16 using namespace mrpt::img;
18 
20 {
21  TColor ret;
22  ret.R = first.R + second.R;
23  ret.G = first.G + second.G;
24  ret.B = first.B + second.B;
25  ret.A = first.A + second.A;
26 
27  return ret;
28 }
29 
31 {
32  TColor ret;
33  ret.R = first.R - second.R;
34  ret.G = first.G - second.G;
35  ret.B = first.B - second.B;
36  ret.A = first.A - second.A;
37 
38  return ret;
39 }
40 
42 {
43  this->R += other.R;
44  this->G += other.G;
45  this->B += other.B;
46  this->A += other.A;
47 
48  return *this;
49 }
50 
52 {
53  this->R -= other.R;
54  this->G -= other.G;
55  this->B -= other.B;
56  this->A -= other.A;
57 
58  return *this;
59 }
60 
61 TColor& TColor::operator=(const TColor& other) = default;
62 
63 bool mrpt::img::operator==(const TColor& first, const TColor& second)
64 {
65  bool ret = first.R == second.R && first.G == second.G &&
66  first.B == second.B && first.A == second.A;
67 
68  return ret;
69 }
70 
71 // bool operator!=(const TColor& first, const TColor& second) {
72 // return (!(first == second));
73 //}
74 
75 // Text streaming:
76 std::ostream& mrpt::img::operator<<(std::ostream& o, const TColor& c)
77 {
78  char buf[200];
80  buf, sizeof(buf), "RGBA=[%u,%u,%u,%u]", static_cast<unsigned int>(c.R),
81  static_cast<unsigned int>(c.G), static_cast<unsigned int>(c.B),
82  static_cast<unsigned int>(c.A));
83  o << buf;
84  return o;
85 }
86 
87 // Binary streaming:
89 {
90  o << c.R << c.G << c.B << c.A;
91  return o;
92 }
93 
95 {
96  i >> c.R >> c.G >> c.B >> c.A;
97  return i;
98 }
99 
100 // Text streaming:
101 std::ostream& mrpt::img::operator<<(std::ostream& o, const TColorf& c)
102 {
103  char buf[200];
105  buf, sizeof(buf), "RGBAf=[%f,%f,%f,%f]", c.R, c.G, c.B, c.A);
106  o << buf;
107  return o;
108 }
109 
110 // Binary streaming:
112 {
113  o << c.R << c.G << c.B << c.A;
114  return o;
115 }
116 
118 {
119  i >> c.R >> c.G >> c.B >> c.A;
120  return i;
121 }
GLint * first
Definition: glext.h:3833
uint8_t B
Definition: TColor.h:46
uint8_t G
Definition: TColor.h:46
TColor operator+(const TColor &first, const TColor &second)
Pairwise addition of their corresponding RGBA members.
Definition: TColor.cpp:19
TColor & operator-=(const TColor &other)
Definition: TColor.cpp:51
const GLubyte * c
Definition: glext.h:6406
uint8_t R
Definition: TColor.h:46
bool operator==(const mrpt::img::TCamera &a, const mrpt::img::TCamera &b)
Definition: TCamera.cpp:202
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:53
A RGB color - floats in the range [0,1].
Definition: TColor.h:77
TColor operator-(const TColor &first, const TColor &second)
Pairwise substraction of their corresponding RGBA members.
Definition: TColor.cpp:30
TColor & operator=(const TColor &other)
TColor & operator+=(const TColor &other)
Definition: TColor.cpp:41
A RGB color - 8bit.
Definition: TColor.h:20
std::ostream & operator<<(std::ostream &o, const TColor &c)
Definition: TColor.cpp:76
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &i, TColor &c)
Definition: TColor.cpp:94
int sprintf(char *buf, size_t bufSize, const char *format,...) noexcept MRPT_printf_format_check(3
An OS-independent version of sprintf (Notice the bufSize param, which may be ignored in some compiler...
Definition: os.cpp:191
uint8_t A
Definition: TColor.h:46



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ce1a28c9f Fri Aug 23 08:02:09 2019 +0200 at vie ago 23 08:10:11 CEST 2019