BSB Developer Docs
Loading...
Searching...
No Matches
color.h File Reference

Color declaration and conversion API. More...

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  Color
 RGB color structure. More...
 
struct  ColorHsv
 HSV color structure. More...
 

Macros

#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.
 

Functions

Color color_hsv_to_rgb (ColorHsv hsv)
 Convert HSV color to RGB color.
 
Color color_hex_to_rgb (uint32_t hex)
 Convert a HEX 0xRRGGBB representation to an RGB color.
 
Color color_hexa_to_rgb (uint32_t hexa)
 Convert a HEX 0xRRGGBBAA representation to an RGB color.
 
bool color_parse_hex_string (const char *hex, Color *color_out)
 Convert a HEX "#RRGGBB" representation to an RGB color.
 
bool color_parse_hexa_string (const char *hexa, Color *color_out)
 Convert a HEX "#RRGGBBAA" representation to an RGB color.
 
uint8_t color_rgb_to_l8 (Color color)
 Convert an RGB color to an L8 luminance value.
 
void color_buf_l8_to_l4 (void *dst, const void *src, size_t size)
 Convert an L8-encoded color data into L4.
 

Detailed Description

Color declaration and conversion API.

Macro Definition Documentation

◆ 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.

Function Documentation

◆ 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
dstdestination buffer
srcsource buffer
sizesize 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
hexHex 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
hexaHex value to convert (0xRRGGBBAA)
Returns
Color structure

◆ color_hsv_to_rgb()

Color color_hsv_to_rgb ( ColorHsv hsv)

Convert HSV color to RGB color.

Parameters
hsvColorHsv 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]hexHex value to convert ("#RRGGBB")
[out]color_outColor 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]hexaHex value to convert ("#RRGGBBAA")
[out]color_outColor 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]colorColor to convert
Returns
Luminance value in the range 0–255