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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019