#ifndef CVD_LA_H #define CVD_LA_H #include namespace CVD { ////////////////////////////// // CVD::La // Template class to represent luminance and alpha components // /// A colour consisting of luminance and alpha components /// @param T The datatype of each component /// @ingroup gImage template class La { public: /// Default constructor. Does nothing. La() { } /// Constructs a colour as specified /// @param l The luminance component /// @param a The alpha component La(T l, T a) : luminance(l) , alpha(a) { } T luminance; ///< The luminance component T alpha; ///< The alpha component /// Assignment operator /// @param c The colour to copy from La& operator=(const La& c) { luminance = c.luminance; alpha = c.alpha; return *this; } /// Assignment operator between two different storage types, using the standard casts as necessary /// @param c The colour to copy from template La& operator=(const La& c) { luminance = static_cast(c.luminance); alpha = static_cast(c.alpha); return *this; } /// Logical equals operator. Returns true if each component is the same. /// @param c La to compare with bool operator==(const La& c) const { return luminance == c.luminance && alpha == c.alpha; } /// Logical not-equals operator. Returns true unless each component is the same. /// @param c La to compare with bool operator!=(const La& c) const { return luminance != c.luminance || alpha != c.alpha; } }; /// Write the colour to a stream in the format "(luminance,alpha)" /// @param os The stream /// @param x The colour object /// @relates La template std::ostream& operator<<(std::ostream& os, const La& x) { return os << "(" << x.luminance << "," << x.alpha << ")"; } /// Write the colour to a stream in the format "(luminance,alpha)" /// @param os The stream /// @param x The colour object /// @relates La inline std::ostream& operator<<(std::ostream& os, const La& x) { return os << "(" << static_cast(x.luminance) << "," << static_cast(x.alpha) << ")"; } } // end namespace #endif