Color conversions and types.
More...
|
|
#define | RGB_MAX (255U) |
| | Maximum value of an RGB color component.
|
| |
|
#define | RGB_MAX_F32 (255.0f) |
| | Maximum value of an RGB color component as a float-32.
|
| |
|
#define | RGB_RANGE (256U) |
| | Total range of RGB values.
|
| |
|
#define | RGB_RANGE_F32 (256.0f) |
| | Total range of RGB values as a float-32.
|
| |
|
#define | HUE_MAX (359U) |
| | Maximum value of hue.
|
| |
|
#define | HUE_MAX_F32 (359.0f) |
| | Maximum value of hue as a float-32.
|
| |
|
#define | HUE_RANGE (360U) |
| | Total range of hue values.
|
| |
|
#define | HUE_RANGE_F32 (360.0f) |
| | Total range of hue values as a float-32.
|
| |
|
#define | HUE_FP_BITS (6U) |
| | Number of fixed-point fractional bits in the internal hue representation.
|
| |
|
#define | HUE(x) ((uint16_t)((x) << HUE_FP_BITS)) |
| | Converts an integer hue to the fixed-point representation.
|
| |
|
#define | HUE_F32(x) ((uint16_t)((x) * (float)(1 << HUE_FP_BITS))) |
| | Converts a float hue to the fixed-point representation.
|
| |
|
#define | HUE_FP_TO_F32(x) ((float)(x) / (float)(1 << HUE_FP_BITS)) |
| | Converts a fixed-point value to a float.
|
| |
|
#define | SATURATION_MAX (100U) |
| | Maximum value of saturation.
|
| |
|
#define | SATURATION_MAX_F32 (100.0f) |
| | Maximum value of saturation as a float-32.
|
| |
|
#define | VALUE_MAX (100U) |
| | Maximum value of the value component of HSV.
|
| |
|
#define | VALUE_MAX_F32 (100.0f) |
| | Maximum value of the value component of HSV as a float-32.
|
| |
|
#define | LIGHTNESS_MAX (100U) |
| | Maximum value of lightness.
|
| |
|
#define | LIGHTNESS_MAX_F32 (100.0f) |
| | Maximum value of lightness as a float-32.
|
| |
Color conversions and types.
◆ color_space_t
Supported color spaces.
| Enumerator |
|---|
| COLOR_SPACE_RGB | Red-green-blue color space.
|
| COLOR_SPACE_HSV | Hue-saturation-value color space.
|
| COLOR_SPACE_HSL | Hue-saturation-lightness color space.
|
◆ color_convert()
Convert a color to a different color space.
- Parameters
-
| to | Desired color space to convert to. |
| [in] | p_in | Pointer to the color in the original color space. |
| [out] | p_out | Pointer to the color for the desired color space. |
◆ color_convert2()
Convert a color to a different color space.
- Parameters
-
| from | Color space to convert from. |
| to | Desired color space to convert to. |
| [in] | p_in | Pointer to the color in the original color space. |
| [out] | p_out | Pointer to the color for the desired color space. |
◆ color_gamma_build()
| void color_gamma_build |
( |
float |
gamma | ) |
|
Updates the gamma table with the provided correction factor.
- Parameters
-
| gamma | The gamma correction factor to use. |
Builds the gamma table using the equation
\[
C_\gamma = 255 * \left( \frac{C}{255} \right)^\gamma + \frac{1}{2}
\]
◆ color_gamma_correct()
Applies gamma correction to an RGB color.
- Parameters
-
| [in,out] | p_in | The color to correct. |
| [out] | p_out | Pointer to write the corrected color, if NULL p_in is edited in place. |
◆ color_parse()
| bool color_parse |
( |
char * |
p_str, |
|
|
color_t * |
p_color_out |
|
) |
| |
Parses a color from a string; must be NULL-terminated.
- Parameters
-
| [in] | p_str | Pointer to the color string to parse; may be modified. |
| [out] | p_color_out | Pointer to store the parsed color. |
- Returns
- true on success, false on failure.