CVD 0.8
Public Member Functions | Public Attributes | Related Functions
CVD::Rgb< T > Class Template Reference

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

#include <rgb.h>

List of all members.

Public Member Functions

 Rgb ()
 Rgb (T r, T g, T b)
template<class S >
 Rgb (const Rgb< S > &rgb)
Rgb< T > & operator= (const Rgb< T > &c)
bool operator== (const Rgb< T > &c) const
bool operator!= (const Rgb< T > &c) const
template<class T2 >
Rgb< T > & operator= (const Rgb< T2 > &c)

Public Attributes

red
green
blue

Related Functions

(Note that these are not member functions.)

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

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

Definition at line 46 of file rgb.h.


Constructor & Destructor Documentation

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

Constructs a colour as specified.

Parameters:
rThe red component
gThe green component
bThe blue component

Definition at line 56 of file rgb.h.


Member Function Documentation

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

Assignment operator.

Parameters:
cThe colour to copy from

Definition at line 66 of file rgb.h.

References CVD::Rgb< T >::blue, CVD::Rgb< T >::green, and CVD::Rgb< T >::red.

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

Definition at line 71 of file rgb.h.

References CVD::Rgb< T >::blue, CVD::Rgb< T >::green, and CVD::Rgb< T >::red.

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

Definition at line 76 of file rgb.h.

References CVD::Rgb< T >::blue, CVD::Rgb< T >::green, and CVD::Rgb< T >::red.

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

Definition at line 82 of file rgb.h.

References CVD::Rgb< T >::blue, CVD::Rgb< T >::green, and CVD::Rgb< T >::red.


Friends And Related Function Documentation

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

Definition at line 97 of file rgb.h.

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

Definition at line 107 of file rgb.h.

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

Definition at line 118 of file rgb.h.


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