メイン・コンテンツまでスキップ

Color

Contains functionality for color conversion.

Public Functions

FORCE_INLINE_FUNCTION uint8_tgetBlue(colortype color)
Gets the blue color part of a color.
FORCE_INLINE_FUNCTION uint8_tgetBlueFromRGB565(uint16_t color)
Gets the blue color part of a 16bpp color also known as RGB565.
FORCE_INLINE_FUNCTION colortypegetColorFromHSL(uint8_t hue, uint8_t saturation, uint8_t luminance)
Convert a given color from HSV (Hue, Saturation, Value) to colortype.
FORCE_INLINE_FUNCTION colortypegetColorFromHSV(uint8_t hue, uint8_t saturation, uint8_t value)
Convert a given color from HSV (Hue, Saturation, Value) to colortype.
FORCE_INLINE_FUNCTION colortypegetColorFromRGB(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_tgetGreen(colortype color)
Gets the green color part of a color.
FORCE_INLINE_FUNCTION uint8_tgetGreenFromRGB565(uint16_t color)
Gets the green color part of a 16bpp color also known as RGB565.
FORCE_INLINE_FUNCTION voidgetHSLFromColor(colortype color, uint8_t & hue, uint8_t & saturation, uint8_t & luminance)
Convert a given colortype color to HSV (Hue, Saturation, Value).
FORCE_INLINE_FUNCTION voidgetHSLFromHSV(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 voidgetHSLFromRGB(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 voidgetHSVFromColor(colortype color, uint8_t & hue, uint8_t & saturation, uint8_t & value)
Convert a given colortype color to HSV (Hue, Saturation, Value).
FORCE_INLINE_FUNCTION voidgetHSVFromHSL(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).
voidgetHSVFromRGB(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_tgetRed(colortype color)
Gets the red color part of a color.
FORCE_INLINE_FUNCTION uint8_tgetRedFromRGB565(uint16_t color)
Gets the red color part of a 16bpp color also known as RGB565.
FORCE_INLINE_FUNCTION voidgetRGBFromColor(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 voidgetRGBFromHSL(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).
voidgetRGBFromHSV(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_trgb565toXrgb8888(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

static FORCE_INLINE_FUNCTION uint8_t getBlue(colortypecolor)

Gets the blue color part of a color.

Parameters:
colorThe color value.
Returns:

The blue part of the color (0 to 255).

getBlueFromRGB565

static FORCE_INLINE_FUNCTION uint8_t getBlueFromRGB565(uint16_tcolor)

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.

Parameters:
colorThe color value in RGB565.
Returns:

The blue part of the color (0 to 255).

getColorFromHSL

static FORCE_INLINE_FUNCTION colortype getColorFromHSL(uint8_thue ,
uint8_tsaturation ,
uint8_tluminance
)

Convert a given color from HSV (Hue, Saturation, Value) to colortype.

Parameters:
hueThe input Hue (0 to 255).
saturationThe input Saturation (0 to 255).
luminanceThe input Value (0 to 255).
Returns:

The colortype color.

Note

The conversion is an approximation.

getColorFromHSV

static FORCE_INLINE_FUNCTION colortype getColorFromHSV(uint8_thue ,
uint8_tsaturation ,
uint8_tvalue
)

Convert a given color from HSV (Hue, Saturation, Value) to colortype.

Parameters:
hueThe input Hue (0 to 255).
saturationThe input Saturation (0 to 255).
valueThe input Value (0 to 255).
Returns:

The colortype color.

Note

The conversion is an approximation.

getColorFromRGB

static FORCE_INLINE_FUNCTION colortype getColorFromRGB(uint8_tred ,
uint8_tgreen ,
uint8_tblue
)

Generates a color representation to be used on the LCD, based on 24 bit RGB values.

The embedded alpha value is set to 255.

Parameters:
redValue of the red part (0 to 255).
greenValue of the green part (0 to 255).
blueValue of the blue part (0 to 255).
Returns:

The color representation depending on LCD color format.

getGreen

static FORCE_INLINE_FUNCTION uint8_t getGreen(colortypecolor)

Gets the green color part of a color.

Parameters:
colorThe color value.
Returns:

The green part of the color (0 to 255).

getGreenFromRGB565

static FORCE_INLINE_FUNCTION uint8_t getGreenFromRGB565(uint16_tcolor)

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.

Parameters:
colorThe color value in RGB565.
Returns:

The green part of the color (0 to 255).

getHSLFromColor

static FORCE_INLINE_FUNCTION void getHSLFromColor(colortypecolor ,
uint8_t &hue ,
uint8_t &saturation ,
uint8_t &luminance
)

Convert a given colortype color to HSV (Hue, Saturation, Value).

Parameters:
colorThe input color.
hueThe output Hue (0 to 255).
saturationThe output Saturation (0 to 255).
luminanceThe output Value (0 to 255).
Note

The conversion is an approximation.

getHSLFromHSV

static FORCE_INLINE_FUNCTION void getHSLFromHSV(uint8_thsv_hue ,
uint8_thsv_saturation ,
uint8_thsv_value ,
uint8_t &hsl_hue ,
uint8_t &hsl_saturation ,
uint8_t &hsl_luminance
)

Convert HSV (Hue, Saturation, Value) to HSL (Hue, Saturation, Luminance).

Parameters:
hsv_hueThe input HSV hue (0 to 255).
hsv_saturationThe input HSV saturation (0 to 255).
hsv_valueThe input HSV value (0 to 255).
hsl_hueThe output HSL hue (0 to 255).
hsl_saturationThe output HSL saturation (0 to 255).
hsl_luminanceThe output HSL luminance (0 to 255).

getHSLFromRGB

static FORCE_INLINE_FUNCTION void getHSLFromRGB(uint8_tred ,
uint8_tgreen ,
uint8_tblue ,
uint8_t &hue ,
uint8_t &saturation ,
uint8_t &luminance
)

Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value).

Parameters:
redThe input Red (0 to 255).
greenThe input Green (0 to 255).
blueThe input Blue (0 to 255).
hueThe output Hue (0 to 255).
saturationThe output Saturation (0 to 255).
luminanceThe output Value (0 to 255).
Note

The conversion is an approximation.

getHSVFromColor

static FORCE_INLINE_FUNCTION void getHSVFromColor(colortypecolor ,
uint8_t &hue ,
uint8_t &saturation ,
uint8_t &value
)

Convert a given colortype color to HSV (Hue, Saturation, Value).

Parameters:
colorThe input color.
hueThe output Hue (0 to 255).
saturationThe output Saturation (0 to 255).
valueThe output Value (0 to 255).
Note

The conversion is an approximation.

getHSVFromHSL

static FORCE_INLINE_FUNCTION void getHSVFromHSL(uint8_thsl_hue ,
uint8_thsl_saturation ,
uint8_thsl_luminance ,
uint8_t &hsv_hue ,
uint8_t &hsv_saturation ,
uint8_t &hsv_value
)

Convert HSL (Hue, Saturation, Luminance) to HSV (Hue, Saturation, Value).

Parameters:
hsl_hueThe input HSL hue (0 to 255).
hsl_saturationThe input HSL saturation (0 to 255).
hsl_luminanceThe input HSL luminance (0 to 255).
hsv_hueThe output HSV hue (0 to 255).
hsv_saturationThe output HSV saturation (0 to 255).
hsv_valueThe output HSV value (0 to 255).

getHSVFromRGB

static void getHSVFromRGB(uint8_tred ,
uint8_tgreen ,
uint8_tblue ,
uint8_t &hue ,
uint8_t &saturation ,
uint8_t &value
)

Convert a given color from RGB (Red, Green, Blue) to HSV (Hue, Saturation, Value).

Parameters:
redThe input Red (0 to 255).
greenThe input Green (0 to 255).
blueThe input Blue (0 to 255).
hueThe output Hue (0 to 255).
saturationThe output Saturation (0 to 255).
valueThe output Value (0 to 255).
Note

The conversion is an approximation.

getRed

static FORCE_INLINE_FUNCTION uint8_t getRed(colortypecolor)

Gets the red color part of a color.

Parameters:
colorThe color value.
Returns:

The red part of the color (0 to 255).

getRedFromRGB565

static FORCE_INLINE_FUNCTION uint8_t getRedFromRGB565(uint16_tcolor)

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.

Parameters:
colorThe color value in RGB565.
Returns:

The red part of the color (0 to 255).

getRGBFromColor

static FORCE_INLINE_FUNCTION void getRGBFromColor(colortypecolor ,
uint8_t &red ,
uint8_t &green ,
uint8_t &blue
)

Split a given colortype color to its RGB (Red, Green, Blue) components.

Parameters:
colorThe input color.
redThe output Red (0 to 255).
greenThe output Green (0 to 255).
blueThe output Blue (0 to 255).

getRGBFromHSL

static FORCE_INLINE_FUNCTION void getRGBFromHSL(uint8_thue ,
uint8_tsaturation ,
uint8_tluminance ,
uint8_t &red ,
uint8_t &green ,
uint8_t &blue
)

Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue).

Parameters:
hueThe input Hue (0 to 255).
saturationThe input Saturation (0 to 255).
luminanceThe input Value (0 to 255).
redThe output Red (0 to 255).
greenThe output Green (0 to 255).
blueThe output Blue (0 to 255).
Note

The conversion is an approximation.

getRGBFromHSV

static void getRGBFromHSV(uint8_thue ,
uint8_tsaturation ,
uint8_tvalue ,
uint8_t &red ,
uint8_t &green ,
uint8_t &blue
)

Convert a given color from HSV (Hue, Saturation, Value) to RGB (Red, Green, Blue).

Parameters:
hueThe input Hue (0 to 255).
saturationThe input Saturation (0 to 255).
valueThe input Value (0 to 255).
redThe output Red (0 to 255).
greenThe output Green (0 to 255).
blueThe output Blue (0 to 255).
Note

The conversion is an approximation.

rgb565toXrgb8888

static FORCE_INLINE_FUNCTION uint32_t rgb565toXrgb8888(uint16_trgb565)

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.

Parameters:
rgb565The 16bit RGB565 color.
Returns:

The 32bit color value.

See also: