Color
Contains functionality for color conversion.
Public Functions
FORCE_INLINE_FUNCTION uint8_t | getBlue(colortype color) |
Gets the blue color part of a color. | |
FORCE_INLINE_FUNCTION uint8_t | getBlueFromRGB565(uint16_t color) |
Gets the blue color part of a 16bpp color also known as RGB565. | |
FORCE_INLINE_FUNCTION colortype | getColorFromHSL(uint8_t hue, uint8_t saturation, uint8_t luminance) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype. | |
FORCE_INLINE_FUNCTION colortype | getColorFromHSV(uint8_t hue, uint8_t saturation, uint8_t value) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype. | |
FORCE_INLINE_FUNCTION colortype | getColorFromRGB(uint8_t red, uint8_t green, uint8_t blue) |
Generates a color representation to be used on the LCD, based on 24 bit RGB values. | |
FORCE_INLINE_FUNCTION uint8_t | getGreen(colortype color) |
Gets the green color part of a color. | |
FORCE_INLINE_FUNCTION uint8_t | getGreenFromRGB565(uint16_t color) |
Gets the green color part of a 16bpp color also known as RGB565. | |
FORCE_INLINE_FUNCTION void | getHSLFromColor(colortype color, uint8_t & hue, uint8_t & saturation, uint8_t & luminance) |
Convert a given colortype color to HSV (Hue, Saturation, Value). | |
FORCE_INLINE_FUNCTION void | getHSLFromHSV(uint8_t hsv_hue, uint8_t hsv_saturation, uint8_t hsv_value, uint8_t & hsl_hue, uint8_t & hsl_saturation, uint8_t & hsl_luminance) |
Convert HSV (Hue, Saturation, Value) to HSL (Hue, Saturation, Luminance). | |
FORCE_INLINE_FUNCTION void | getHSLFromRGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t & hue, uint8_t & saturation, uint8_t & luminance) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value). | |
FORCE_INLINE_FUNCTION void | getHSVFromColor(colortype color, uint8_t & hue, uint8_t & saturation, uint8_t & value) |
Convert a given colortype color to HSV (Hue, Saturation, Value). | |
FORCE_INLINE_FUNCTION void | getHSVFromHSL(uint8_t hsl_hue, uint8_t hsl_saturation, uint8_t hsl_luminance, uint8_t & hsv_hue, uint8_t & hsv_saturation, uint8_t & hsv_value) |
Convert HSL (Hue, Saturation, Luminance) to HSV (Hue, Saturation, Value). | |
void | getHSVFromRGB(uint8_t red, uint8_t green, uint8_t blue, uint8_t & hue, uint8_t & saturation, uint8_t & value) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value). | |
FORCE_INLINE_FUNCTION uint8_t | getRed(colortype color) |
Gets the red color part of a color. | |
FORCE_INLINE_FUNCTION uint8_t | getRedFromRGB565(uint16_t color) |
Gets the red color part of a 16bpp color also known as RGB565. | |
FORCE_INLINE_FUNCTION void | getRGBFromColor(colortype color, uint8_t & red, uint8_t & green, uint8_t & blue) |
Split a given colortype color to its RGB (Red, Green, Blue) components. | |
FORCE_INLINE_FUNCTION void | getRGBFromHSL(uint8_t hue, uint8_t saturation, uint8_t luminance, uint8_t & red, uint8_t & green, uint8_t & blue) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue). | |
void | getRGBFromHSV(uint8_t hue, uint8_t saturation, uint8_t value, uint8_t & red, uint8_t & green, uint8_t & blue) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue). | |
FORCE_INLINE_FUNCTION uint32_t | rgb565toXrgb8888(uint16_t rgb565) |
Convert 16bit RGB565 color to 32bit ARGB8888 color by expanding the 5,6,5 colors to full 8,8, 8 colors. | |
Public Functions Documentation
getBlue
Gets the blue color part of a color.
color | The color value. |
The blue part of the color (0 to 255).
getBlueFromRGB565
static FORCE_INLINE_FUNCTION uint8_t getBlueFromRGB565 | ( | uint16_t | color | ) | |
Gets the blue color part of a 16bpp color also known as RGB565.
The blue part (5 bits) is extracted and scaled to the full 0-255 byte range.
color | The color value in RGB565. |
The blue part of the color (0 to 255).
getColorFromHSL
static FORCE_INLINE_FUNCTION colortype getColorFromHSL | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | luminance | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype.
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
luminance | The input Value (0 to 255). |
The colortype color.
Note
The conversion is an approximation.
getColorFromHSV
static FORCE_INLINE_FUNCTION colortype getColorFromHSV | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | value | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to colortype.
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
value | The input Value (0 to 255). |
The colortype color.
Note
The conversion is an approximation.
getColorFromRGB
static FORCE_INLINE_FUNCTION colortype getColorFromRGB | ( | uint8_t | red , | ||
uint8_t | green , | ||||
uint8_t | blue | ||||
) |
Generates a color representation to be used on the LCD, based on 24 bit RGB values.
The embedded alpha value is set to 255.
red | Value of the red part (0 to 255). |
green | Value of the green part (0 to 255). |
blue | Value of the blue part (0 to 255). |
The color representation depending on LCD color format.
getGreen
Gets the green color part of a color.
color | The color value. |
The green part of the color (0 to 255).
getGreenFromRGB565
static FORCE_INLINE_FUNCTION uint8_t getGreenFromRGB565 | ( | uint16_t | color | ) | |
Gets the green color part of a 16bpp color also known as RGB565.
The green part (6 bits) is extracted and scaled to the full 0-255 byte range.
color | The color value in RGB565. |
The green part of the color (0 to 255).
getHSLFromColor
static FORCE_INLINE_FUNCTION void getHSLFromColor | ( | colortype | color , | ||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | luminance | ||||
) |
Convert a given colortype color to HSV (Hue, Saturation, Value).
color | The input color. |
hue | The output Hue (0 to 255). |
saturation | The output Saturation (0 to 255). |
luminance | The output Value (0 to 255). |
Note
The conversion is an approximation.
getHSLFromHSV
static FORCE_INLINE_FUNCTION void getHSLFromHSV | ( | uint8_t | hsv_hue , | ||
uint8_t | hsv_saturation , | ||||
uint8_t | hsv_value , | ||||
uint8_t & | hsl_hue , | ||||
uint8_t & | hsl_saturation , | ||||
uint8_t & | hsl_luminance | ||||
) |
Convert HSV (Hue, Saturation, Value) to HSL (Hue, Saturation, Luminance).
hsv_hue | The input HSV hue (0 to 255). |
hsv_saturation | The input HSV saturation (0 to 255). |
hsv_value | The input HSV value (0 to 255). |
hsl_hue | The output HSL hue (0 to 255). |
hsl_saturation | The output HSL saturation (0 to 255). |
hsl_luminance | The output HSL luminance (0 to 255). |
getHSLFromRGB
static FORCE_INLINE_FUNCTION void getHSLFromRGB | ( | uint8_t | red , | ||
uint8_t | green , | ||||
uint8_t | blue , | ||||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | luminance | ||||
) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value).
red | The input Red (0 to 255). |
green | The input Green (0 to 255). |
blue | The input Blue (0 to 255). |
hue | The output Hue (0 to 255). |
saturation | The output Saturation (0 to 255). |
luminance | The output Value (0 to 255). |
Note
The conversion is an approximation.
getHSVFromColor
static FORCE_INLINE_FUNCTION void getHSVFromColor | ( | colortype | color , | ||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | value | ||||
) |
Convert a given colortype color to HSV (Hue, Saturation, Value).
color | The input color. |
hue | The output Hue (0 to 255). |
saturation | The output Saturation (0 to 255). |
value | The output Value (0 to 255). |
Note
The conversion is an approximation.
getHSVFromHSL
static FORCE_INLINE_FUNCTION void getHSVFromHSL | ( | uint8_t | hsl_hue , | ||
uint8_t | hsl_saturation , | ||||
uint8_t | hsl_luminance , | ||||
uint8_t & | hsv_hue , | ||||
uint8_t & | hsv_saturation , | ||||
uint8_t & | hsv_value | ||||
) |
Convert HSL (Hue, Saturation, Luminance) to HSV (Hue, Saturation, Value).
hsl_hue | The input HSL hue (0 to 255). |
hsl_saturation | The input HSL saturation (0 to 255). |
hsl_luminance | The input HSL luminance (0 to 255). |
hsv_hue | The output HSV hue (0 to 255). |
hsv_saturation | The output HSV saturation (0 to 255). |
hsv_value | The output HSV value (0 to 255). |
getHSVFromRGB
static void getHSVFromRGB | ( | uint8_t | red , | ||
uint8_t | green , | ||||
uint8_t | blue , | ||||
uint8_t & | hue , | ||||
uint8_t & | saturation , | ||||
uint8_t & | value | ||||
) |
Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value).
red | The input Red (0 to 255). |
green | The input Green (0 to 255). |
blue | The input Blue (0 to 255). |
hue | The output Hue (0 to 255). |
saturation | The output Saturation (0 to 255). |
value | The output Value (0 to 255). |
Note
The conversion is an approximation.
getRed
Gets the red color part of a color.
color | The color value. |
The red part of the color (0 to 255).
getRedFromRGB565
static FORCE_INLINE_FUNCTION uint8_t getRedFromRGB565 | ( | uint16_t | color | ) | |
Gets the red color part of a 16bpp color also known as RGB565.
The red part (5 bits) is extracted and scaled to the full 0-255 byte range.
color | The color value in RGB565. |
The red part of the color (0 to 255).
getRGBFromColor
static FORCE_INLINE_FUNCTION void getRGBFromColor | ( | colortype | color , | ||
uint8_t & | red , | ||||
uint8_t & | green , | ||||
uint8_t & | blue | ||||
) |
Split a given colortype color to its RGB (Red, Green, Blue) components.
color | The input color. |
red | The output Red (0 to 255). |
green | The output Green (0 to 255). |
blue | The output Blue (0 to 255). |
getRGBFromHSL
static FORCE_INLINE_FUNCTION void getRGBFromHSL | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | luminance , | ||||
uint8_t & | red , | ||||
uint8_t & | green , | ||||
uint8_t & | blue | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue).
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
luminance | The input Value (0 to 255). |
red | The output Red (0 to 255). |
green | The output Green (0 to 255). |
blue | The output Blue (0 to 255). |
Note
The conversion is an approximation.
getRGBFromHSV
static void getRGBFromHSV | ( | uint8_t | hue , | ||
uint8_t | saturation , | ||||
uint8_t | value , | ||||
uint8_t & | red , | ||||
uint8_t & | green , | ||||
uint8_t & | blue | ||||
) |
Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue).
hue | The input Hue (0 to 255). |
saturation | The input Saturation (0 to 255). |
value | The input Value (0 to 255). |
red | The output Red (0 to 255). |
green | The output Green (0 to 255). |
blue | The output Blue (0 to 255). |
Note
The conversion is an approximation.
rgb565toXrgb8888
static FORCE_INLINE_FUNCTION uint32_t rgb565toXrgb8888 | ( | uint16_t | rgb565 | ) | |
Convert 16bit RGB565 color to 32bit ARGB8888 color by expanding the 5,6,5 colors to full 8,8, 8 colors.
The alpha value is set to zero.
rgb565 | The 16bit RGB565 color. |
The 32bit color value.