I got two class templates Color3_t and Color4_t that store 3 and 4 color channels and look like this:
template <typename TYPE>
struct Color3_t
{
TYPE Red;
TYPE Green;
TYPE Blue;
void Zero()
{
Red = Green = Blue = 0;
}
(...)
}
Both templates have several function for inverting, swapping etc. color channels and I got another specialized templates that inherit these classes - in case the TYPE is a half float or float instead of integer.
The problem is that the order of color channels : Red,Green and Blue is currently fixed - which means that I would have to create a version of Color3_t class template for each other order of color channels (like BGR, GRB etc.). How can provide and argument with different color order - most likely that points to a color structure like below.
Color data structures for RGB and BGR color order:
template <typename TYPE>
struct ColorRGB_t
{
TYPE Red;
TYPE Green;
TYPE Blue;
};
template <typename TYPE>
struct ColorBGR_t
{
TYPE Blue;
TYPE Green;
TYPE Red;
};
and something I'd like to have - which is obviously wrong and incorrect but should give an idea what I want to achieve.
template <typename TYPE, class COLORORDER<TYPE>>
struct Color3_t : public COLORORDER<TYPE>
{
void Zero()
{
Red = Green = Blue = 0;
}
(...)
};
I also would like to access each color channel directly:
typedef Color3_t<BYTE,ColorBGR_t<BYTE>> ColorRGB8bpc;
ColorRGB8bpc oColor;
oColor.Red = 0;
instead of:
oColor.SomoObject.Red = 0;