Color declaration and conversion API.
More...
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
Go to the source code of this file.
|
| #define | COLOR_MAKE_RGB(rv, gv, bv) |
| | Converts an R, G, B representation into a color.
|
| |
| #define | COLOR_MAKE_RGBA(rv, gv, bv, av) |
| | Converts an R, G, B, A representation into a color.
|
| |
| #define | COLOR_MAKE_HEX(hex) |
| | Converts an 0xRRGGBB representation into a color.
|
| |
| #define | COLOR_MAKE_HEXA(hexa) |
| | Converts an 0xRRGGBBAA representation into a color.
|
| |
Color declaration and conversion API.
◆ COLOR_MAKE_HEX
| #define COLOR_MAKE_HEX |
( |
| hex | ) |
|
Value: {.b = (hex) & 0xFF, .g = ((hex) >> 8) & 0xFF, .r = ((hex) >> 16) & 0xFF, .a = 255}
Converts an 0xRRGGBB representation into a color.
◆ COLOR_MAKE_HEXA
| #define COLOR_MAKE_HEXA |
( |
| hexa | ) |
|
Value: {.a = (hexa) & 0xFF, \
.b = ((hexa) >> 8) & 0xFF, \
.g = ((hexa) >> 16) & 0xFF, \
.r = ((hexa) >> 24) & 0xFF}
Converts an 0xRRGGBBAA representation into a color.
◆ COLOR_MAKE_RGB
| #define COLOR_MAKE_RGB |
( |
| rv, |
|
|
| gv, |
|
|
| bv ) |
Value:{.b = (bv), .g = (gv), .r = (rv), .a = 255}
Converts an R, G, B representation into a color.
◆ COLOR_MAKE_RGBA
| #define COLOR_MAKE_RGBA |
( |
| rv, |
|
|
| gv, |
|
|
| bv, |
|
|
| av ) |
Value:{.b = (bv), .g = (gv), .r = (rv), .a = (av)}
Converts an R, G, B, A representation into a color.
◆ color_buf_l8_to_l4()
| void color_buf_l8_to_l4 |
( |
void * | dst, |
|
|
const void * | src, |
|
|
size_t | size ) |
Convert an L8-encoded color data into L4.
- Parameters
-
| dst | destination buffer |
| src | source buffer |
| size | size of source buffer. Destination buffer must hold at least size/2 bytes. |
◆ color_hex_to_rgb()
| Color color_hex_to_rgb |
( |
uint32_t | hex | ) |
|
Convert a HEX 0xRRGGBB representation to an RGB color.
- Parameters
-
| hex | Hex value to convert (0xRRGGBB) |
- Returns
- Color structure
◆ color_hexa_to_rgb()
| Color color_hexa_to_rgb |
( |
uint32_t | hexa | ) |
|
Convert a HEX 0xRRGGBBAA representation to an RGB color.
- Parameters
-
| hexa | Hex value to convert (0xRRGGBBAA) |
- Returns
- Color structure
◆ color_hsv_to_rgb()
Convert HSV color to RGB color.
- Parameters
-
| hsv | ColorHsv structure to convert |
- Returns
- Color structure
◆ color_parse_hex_string()
| bool color_parse_hex_string |
( |
const char * | hex, |
|
|
Color * | color_out ) |
Convert a HEX "#RRGGBB" representation to an RGB color.
- Parameters
-
| [in] | hex | Hex value to convert ("#RRGGBB") |
| [out] | color_out | Color structure to fill |
- Returns
- Parsing status (
true = success)
◆ color_parse_hexa_string()
| bool color_parse_hexa_string |
( |
const char * | hexa, |
|
|
Color * | color_out ) |
Convert a HEX "#RRGGBBAA" representation to an RGB color.
- Parameters
-
| [in] | hexa | Hex value to convert ("#RRGGBBAA") |
| [out] | color_out | Color structure to fill |
- Returns
- Parsing status (
true = success)
◆ color_rgb_to_l8()
| uint8_t color_rgb_to_l8 |
( |
Color | color | ) |
|
Convert an RGB color to an L8 luminance value.
- Parameters
-
| [in] | color | Color to convert |
- Returns
- Luminance value in the range 0–255