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-2017, 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 "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/utils/CStream.h>
13 #include <mrpt/utils/TColor.h>
14 #include <mrpt/system/os.h>
15 
16 using namespace mrpt::utils;
17 
19 {
20  TColor ret;
21  ret.R = first.R + second.R;
22  ret.G = first.G + second.G;
23  ret.B = first.B + second.B;
24  ret.A = first.A + second.A;
25 
26  return ret;
27 }
28 
30 {
31  TColor ret;
32  ret.R = first.R - second.R;
33  ret.G = first.G - second.G;
34  ret.B = first.B - second.B;
35  ret.A = first.A - second.A;
36 
37  return ret;
38 }
39 
41 {
42  this->R += other.R;
43  this->G += other.G;
44  this->B += other.B;
45  this->A += other.A;
46 
47  return *this;
48 }
49 
51 {
52  this->R -= other.R;
53  this->G -= other.G;
54  this->B -= other.B;
55  this->A -= other.A;
56 
57  return *this;
58 }
59 
61 {
62  this->R = other.R;
63  this->G = other.G;
64  this->B = other.B;
65  this->A = other.A;
66 
67  return *this;
68 }
69 
70 bool mrpt::utils::operator==(const TColor& first, const TColor& second)
71 {
72  bool ret = first.R == second.R && first.G == second.G &&
73  first.B == second.B && first.A == second.A;
74 
75  return ret;
76 }
77 
78 // bool operator!=(const TColor& first, const TColor& second) {
79 // return (!(first == second));
80 //}
81 
82 // Text streaming:
83 std::ostream& mrpt::utils::operator<<(std::ostream& o, const TColor& c)
84 {
85  char buf[200];
87  buf, sizeof(buf), "RGBA=[%u,%u,%u,%u]", static_cast<unsigned int>(c.R),
88  static_cast<unsigned int>(c.G), static_cast<unsigned int>(c.B),
89  static_cast<unsigned int>(c.A));
90  o << buf;
91  return o;
92 }
93 
94 // Binary streaming:
96 {
97  o << c.R << c.G << c.B << c.A;
98  return o;
99 }
100 
102 {
103  i >> c.R >> c.G >> c.B >> c.A;
104  return i;
105 }
106 
107 // Text streaming:
108 std::ostream& mrpt::utils::operator<<(std::ostream& o, const TColorf& c)
109 {
110  char buf[200];
112  buf, sizeof(buf), "RGBAf=[%f,%f,%f,%f]", c.R, c.G, c.B, c.A);
113  o << buf;
114  return o;
115 }
116 
117 // Binary streaming:
119 {
120  o << c.R << c.G << c.B << c.A;
121  return o;
122 }
123 
125 {
126  i >> c.R >> c.G >> c.B >> c.A;
127  return i;
128 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
TColor & operator+=(const TColor &other)
Definition: TColor.cpp:40
GLint * first
Definition: glext.h:3827
bool operator==(const mrpt::utils::TCamera &a, const mrpt::utils::TCamera &b)
Definition: TCamera.cpp:204
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
TColor & operator-=(const TColor &other)
Definition: TColor.cpp:50
const GLubyte * c
Definition: glext.h:6313
TColor operator-(const TColor &first, const TColor &second)
Pairwise substraction of their corresponding RGBA members.
Definition: TColor.cpp:29
A RGB color - 8bit.
Definition: TColor.h:25
CStream & operator<<(mrpt::utils::CStream &s, const char *a)
Definition: CStream.cpp:123
TColor operator+(const TColor &first, const TColor &second)
Pairwise addition of their corresponding RGBA members.
Definition: TColor.cpp:18
A RGB color - floats in the range [0,1].
Definition: TColor.h:78
CStream & operator>>(mrpt::utils::CStream &in, char *a)
Definition: CStream.cpp:407
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:188
TColor & operator=(const TColor &other)
Definition: TColor.cpp:60



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019