This union represents 4-component(RGBA) color value.
You can find more information in comments below.
union Color
{
struct
{
unsigned char R; // Red channel
unsigned char G; // Green channel
unsigned char B; // Blue channel
unsigned char A; // Alpha/transparency channel
};
struct
{
unsigned char Red;
unsigned char Green;
unsigned char Blue;
unsigned char Alpha;
};
unsigned char Data[4]; // Channels
unsigned char operator[](const int channel) const; // Get channel value
unsigned char &operator[](const int channel); // Get channel value
unsigned char average() const; // Return average value over all channels except the last one(grayscale)
};
Following operators are also available.
bool operator==(const Color &a, const Color &b); // Check if colors are equal
bool operator!=(const Color &a, const Color &b); // Check if colors are not equal
Color operator*(const Color &a, const Color &b); // Blend colors
Color operator+(const Color &a, const Color &b); // Add(blCanvas mode) colors
Color &operator*=(Color &a, const Color &b); // Blend colors in first one
Color &operator+=(Color &a, const Color &b); // Add(blCanvas mode) colors and store result in first one
std::wostream &operator<<(std::wostream &stream, const Color &a); // Output as source code
Namespace: | nitisa |
Include: |
Nitisa/Core/Bitmap/Color.h (For union declaration) Nitisa/Core/Bitmap/ColorUtils.h (For standalone operators) |