跳轉到主要內容

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_tgetBlueColor(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 colortypegetColorFrom24BitRGB(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 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_tgetGreenColor(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 voidgetHSLFrom24BitRGB(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 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 voidgetHSLFromHSV(uint8_t hue, uint8_t & saturation, uint8_t value, uint8_t & 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 voidgetHSVFrom24BitRGB(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 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).
FORCE_INLINE_FUNCTION voidgetHSVFromHSL(uint8_t hue, uint8_t & saturation, uint8_t luminance, uint8_t & 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_tgetRedColor(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 voidgetRGBFrom24BitHSL(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).
FORCE_INLINE_FUNCTION voidgetRGBFrom24BitHSV(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 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.

getBlueColor

static FORCE_INLINE_FUNCTION uint8_t getBlueColor(colortypecolor)

Gets the blue color part of a color.

Parameters:
colorThe color value.
Returns:

The blue part of the color.

Deprecated

Use getBlue(colortype)

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.

getColorFrom24BitRGB

static FORCE_INLINE_FUNCTION colortype getColorFrom24BitRGB(uint8_tred ,
uint8_tgreen ,
uint8_tblue
)

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

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

The color representation depending on LCD color format.

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-255).
greenValue of the green part (0-255).
blueValue of the blue part (0-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.

getGreenColor

static FORCE_INLINE_FUNCTION uint8_t getGreenColor(colortypecolor)

Gets the green color part of a color.

Parameters:
colorThe color value.
Returns:

The green part of the color.

Deprecated

Use getGreen(colortype)

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.

getHSLFrom24BitRGB

static FORCE_INLINE_FUNCTION void getHSLFrom24BitRGB(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.

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

getHSLFromHSV

static FORCE_INLINE_FUNCTION void getHSLFromHSV(uint8_thue ,
uint8_t &saturation ,
uint8_tvalue ,
uint8_t &luminance
)

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

The Hue is unaltered, the Saturation is changed and the Luminance is calculated.

Parameters:
hueThe hue (0 to 255).
saturationThe saturation (0 to 255).
valueThe value (0 to 255).
luminanceThe luminance (0 to 255).
Deprecated

Use getHSLFromHSV(uint8_t,uint8_t,int8_t,uint8_t&,uint8_t&,uint8_t&)

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.

getHSVFrom24BitRGB

static FORCE_INLINE_FUNCTION void getHSVFrom24BitRGB(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.
greenThe input Green.
blueThe input Blue.
hueThe output Hue.
saturationThe output Saturation.
valueThe output Value.
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).

getHSVFromHSL

static FORCE_INLINE_FUNCTION void getHSVFromHSL(uint8_thue ,
uint8_t &saturation ,
uint8_tluminance ,
uint8_t &value
)

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

The Hue is unaltered, the Saturation is changed and the Value is calculated.

Parameters:
hueThe hue (0 to 255).
saturationThe saturation (0 to 255).
luminanceThe luminance (0 to 255).
valueThe value (0 to 255).
Deprecated

Use getHSVFromHSL(uint8_t,uint8_t,int8_t,uint8_t&,uint8_t&,uint8_t&)

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.
greenThe input Green.
blueThe input Blue.
hueThe output Hue.
saturationThe output Saturation.
valueThe output Value.
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.

getRedColor

static FORCE_INLINE_FUNCTION uint8_t getRedColor(colortypecolor)

Gets the red color part of a color.

Parameters:
colorThe color value.
Returns:

The red part of the color.

Deprecated

Use getRed(colortype)

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.

getRGBFrom24BitHSL

static FORCE_INLINE_FUNCTION void getRGBFrom24BitHSL(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.

getRGBFrom24BitHSV

static FORCE_INLINE_FUNCTION void getRGBFrom24BitHSV(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.

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: