libcvd
Public Member Functions | Public Attributes | Related Functions | List of all members
CVD::Rgb< T > Class Template Reference

A colour consisting of red, green and blue components. More...

#include <rgb.h>

Collaboration diagram for CVD::Rgb< T >:
Collaboration graph
[legend]

Public Member Functions

 Rgb (const Rgb &)=default
 
Rgb & operator= (const Rgb &)=default
 
 Rgb (T r, T g, T b)
 Constructs a colour as specified. More...
 
template<class S >
 Rgb (const Rgb< S > &rgb)
 
bool operator== (const Rgb< T > &c) const
 Logical equals operator. More...
 
bool operator!= (const Rgb< T > &c) const
 Logical not-equals operator. More...
 
template<class T2 >
Rgb< T > & operator= (const Rgb< T2 > &c)
 Assignment operator between two different storage types, using the standard casts as necessary. More...
 

Public Attributes

T red
 The red component.
 
T green
 The green component.
 
T blue
 The blue component.
 

Related Functions

(Note that these are not member functions.)

template<class T >
std::ostream & operator<< (std::ostream &os, const Rgb< T > &x)
 Write the colour to a stream in the format "(red,green,blue)". More...
 
std::ostream & operator<< (std::ostream &os, const Rgb< char > &x)
 Read a colour from a stream, interpreting three numbers as chars. More...
 
std::ostream & operator<< (std::ostream &os, const Rgb< byte > &x)
 Read a colour from a stream, interpreting three numbers as bytes. More...
 

Detailed Description

template<class T>
class CVD::Rgb< T >

A colour consisting of red, green and blue components.

Often used to store 24-bit colour information, i.e. CVD::Rgb<CVD::byte>

Parameters
TThe datatype of each component

Constructor & Destructor Documentation

◆ Rgb()

template<class T>
CVD::Rgb< T >::Rgb ( T  r,
T  g,
T  b 
)
inline

Constructs a colour as specified.

Parameters
rThe red component
gThe green component
bThe blue component

Member Function Documentation

◆ operator!=()

template<class T>
bool CVD::Rgb< T >::operator!= ( const Rgb< T > &  c) const
inline

Logical not-equals operator.

Returns true unless each component is the same.

Parameters
cRgb to compare with

◆ operator=()

template<class T>
template<class T2 >
Rgb<T>& CVD::Rgb< T >::operator= ( const Rgb< T2 > &  c)
inline

Assignment operator between two different storage types, using the standard casts as necessary.

Parameters
cThe colour to copy from

◆ operator==()

template<class T>
bool CVD::Rgb< T >::operator== ( const Rgb< T > &  c) const
inline

Logical equals operator.

Returns true if each component is the same.

Parameters
cRgb to compare with

Friends And Related Function Documentation

◆ operator<<() [1/3]

template<class T >
std::ostream & operator<< ( std::ostream &  os,
const Rgb< T > &  x 
)
related

Write the colour to a stream in the format "(red,green,blue)".

Parameters
osThe stream
xThe colour object

◆ operator<<() [2/3]

template<class T>
std::ostream & operator<< ( std::ostream &  os,
const Rgb< char > &  x 
)
related

Read a colour from a stream, interpreting three numbers as chars.

Parameters
osThe stream
xThe colour object

◆ operator<<() [3/3]

template<class T>
std::ostream & operator<< ( std::ostream &  os,
const Rgb< byte > &  x 
)
related

Read a colour from a stream, interpreting three numbers as bytes.

Parameters
osThe stream
xThe colour object

The documentation for this class was generated from the following file: