MPLABĀ® Harmony Graphics Suite  GFX v3.13.0
Legato API Documentation
legato_color.h File Reference

Color definitions and functions. More...

Include dependency graph for legato_color.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  leColorModeInfo
 This struct represents color mode information. More...
 
struct  leBlendLookupTable
 This struct represents a blend color lookup table. More...
 

Macros

#define LE_COLOR_MODE_LAST_COLOR   (LE_COLOR_MODE_MONOCHROME)
 
#define LE_COLOR_MODE_COUNT   (LE_COLOR_MODE_LAST_COLOR + 1)
 
#define LE_COLOR_MODE_IS_PIXEL(mode)   ((mode >= LE_COLOR_MODE_GS_8) && (mode <= LE_COLOR_MODE_ARGB_8888))
 
#define LE_COLOR_MODE_IS_INDEX(mode)   ((mode >= LE_COLOR_MODE_INDEX_1) && (mode <= LE_COLOR_MODE_INDEX_8))
 
#define LE_COLOR_MODE_IS_ALPHA(mode)   ((mode == LE_COLOR_MODE_RGBA_5551) || (mode == LE_COLOR_MODE_RGBA_8888) || (mode == LE_COLOR_MODE_ARGB_8888))
 

Typedefs

typedef enum leColorMask leColorMask
 This enum represents the color masks for color modes. More...
 
typedef enum leColorMode leColorMode
 This enum represents the supported RGB color formats. More...
 
typedef enum leBitsPerPixel leBitsPerPixel
 This enum represents the bits per pixel (bpp) options. More...
 
typedef struct leColorModeInfo leColorModeInfo
 This struct represents color mode information. More...
 
typedef enum leColorName leColorName
 This enum represents predefined color options.
 
typedef struct leBlendLookupTable leBlendLookupTable
 This struct represents a blend color lookup table. More...
 

Enumerations

enum  leColorMask {
  LE_COLOR_MASK_GS_8 = 0x1, LE_COLOR_MASK_PALETTE = 0x1, LE_COLOR_MASK_RGB_332 = 0x4, LE_COLOR_MASK_RGB_565 = 0x8,
  LE_COLOR_MASK_RGBA_5551 = 0x10, LE_COLOR_MASK_RGB_888 = 0x20, LE_COLOR_MASK_RGBA_8888 = 0x40, LE_COLOR_MASK_ARGB_8888 = 0x80,
  LE_COLOR_MASK_ALL
}
 This enum represents the color masks for color modes. More...
 
enum  leColorMode {
  LE_COLOR_MODE_GS_8 = 0, LE_COLOR_MODE_RGB_332 = 1, LE_COLOR_MODE_RGB_565 = 2, LE_COLOR_MODE_RGBA_5551 = 3,
  LE_COLOR_MODE_RGB_888 = 4, LE_COLOR_MODE_RGBA_8888 = 5, LE_COLOR_MODE_ARGB_8888 = 6, LE_COLOR_MODE_INDEX_1 = 7,
  LE_COLOR_MODE_INDEX_4 = 8, LE_COLOR_MODE_INDEX_8 = 9, LE_COLOR_MODE_PALETTE = LE_COLOR_MODE_INDEX_8, LE_COLOR_MODE_MONOCHROME = 10
}
 This enum represents the supported RGB color formats. More...
 
enum  leBitsPerPixel {
  LE_BPP1, LE_BPP4, LE_BPP8, LE_BPP16,
  LE_BPP24, LE_BPP32
}
 This enum represents the bits per pixel (bpp) options. More...
 
enum  leColorName {
  LE_COLOR_BLACK, LE_COLOR_WHITE, LE_COLOR_RED, LE_COLOR_LIME,
  LE_COLOR_BLUE, LE_COLOR_YELLOW, LE_COLOR_CYAN, LE_COLOR_MAGENTA,
  LE_COLOR_SILVER, LE_COLOR_DARKGRAY, LE_COLOR_GRAY, LE_COLOR_LIGHTGRAY,
  LE_COLOR_MAROON, LE_COLOR_OLIVE, LE_COLOR_GREEN, LE_COLOR_PURPLE,
  LE_COLOR_TEAL, LE_COLOR_NAVY, LE_COLOR_LAST
}
 This enum represents predefined color options.
 

Functions

leColor leColorValue (leColorMode mode, leColorName name)
 Get color by name and mode. More...
 
uint32_t leColorChannelRed (leColor clr, leColorMode mode)
 Get red color channel. More...
 
uint32_t leColorChannelGreen (leColor clr, leColorMode mode)
 Get green color channel. More...
 
uint32_t leColorChannelBlue (leColor clr, leColorMode mode)
 Get blue color channel. More...
 
uint32_t leColorChannelAlpha (leColor clr, leColorMode mode)
 Get alpha color channel. More...
 
leColor leColorConvert (leColorMode mode_in, leColorMode mode_out, leColor color)
 Convert to color value. More...
 
leColor leColorBlend_RGBA_8888 (leColor fore, leColor back)
 Get color from RGBA blend. More...
 
leColor leColorBlend_ARGB_8888 (leColor fore, leColor back)
 Get color from ARGB blend. More...
 
leColor leColorLerp (leColor l, leColor r, uint32_t percent, leColorMode mode)
 Get color from linear interpolate of two colors. More...
 
leColor leColorBilerp (leColor c00, leColor c01, leColor c10, leColor c11, uint32_t xper, uint32_t yper, leColorMode mode)
 Get color from bi-linear interpolation of four colors. More...
 
leColor leColorSwap (leColor clr, leColorMode mode)
 Swaps the red and blue channels for a given color value. More...
 

Variables

const leColorModeInfo leColorInfoTable []
 This array represents information reference table. More...
 

Detailed Description

Color definitions and functions.

Contains functions for color information and manipulation operations. Color conversion and color channel management.

Typedef Documentation

◆ leBitsPerPixel

This enum represents the bits per pixel (bpp) options.

The BPP controls the color depth and bit needed to hold a color. Higher bpp allows for more colours to be represented, however, more resources are required to store or display.

◆ leBlendLookupTable

This struct represents a blend color lookup table.

A blend color lookup table is allows for a fast blending result based on a lookup table versus having to perform the calculation mathematically.

◆ leColorMask

typedef enum leColorMask leColorMask

This enum represents the color masks for color modes.

◆ leColorMode

typedef enum leColorMode leColorMode

This enum represents the supported RGB color formats.

The pixels in a graphics buffer or supported display is represented by the pixel format. For embedded graphics this is limited by memory and hardware.

◆ leColorModeInfo

This struct represents color mode information.

Color mode information keeps track of size, bpp, color channel mask and color.

Enumeration Type Documentation

◆ leBitsPerPixel

This enum represents the bits per pixel (bpp) options.

The BPP controls the color depth and bit needed to hold a color. Higher bpp allows for more colours to be represented, however, more resources are required to store or display.

◆ leColorMask

This enum represents the color masks for color modes.

◆ leColorMode

This enum represents the supported RGB color formats.

The pixels in a graphics buffer or supported display is represented by the pixel format. For embedded graphics this is limited by memory and hardware.

Function Documentation

◆ leColorBilerp()

leColor leColorBilerp ( leColor  c00,
leColor  c01,
leColor  c10,
leColor  c11,
uint32_t  xper,
uint32_t  yper,
leColorMode  mode 
)

Get color from bi-linear interpolation of four colors.

Gets a color from the bilinear interpolation of c00, c01, c10, and c11. The percentage of interpolation of x and y is specified by xper yper. The color format is mode.

Parameters
c00is the top left color input.
c01is the top right color input.
c10is the bottom left color input.
c11is the bottom right color input.
xperis the percentage of interpolation in x [0-100].
yperis the percentage of interpolation in y [0-100].
modeis the input color mode.
Returns
the result color.
Here is the call graph for this function:

◆ leColorBlend_ARGB_8888()

leColor leColorBlend_ARGB_8888 ( leColor  fore,
leColor  back 
)

Get color from ARGB blend.

Gets a color from the blend of ARGB fore and RGBA back.

leColor fore;
leColor back;
leColor blend = leColorBlend_ARGB_8888(fore, back);
Parameters
foreis the foreground color.
backis the background color
Returns
the blended result color.

◆ leColorBlend_RGBA_8888()

leColor leColorBlend_RGBA_8888 ( leColor  fore,
leColor  back 
)

Get color from RGBA blend.

Gets a color from the blend of RGBA fore and RGBA back.

leColor fore;
leColor back;
leColor blend = leColorBlend_RGBA_8888(fore, back);
Parameters
foreis the foreground color.
backis the background color
Returns
the blended result color.

◆ leColorChannelAlpha()

uint32_t leColorChannelAlpha ( leColor  clr,
leColorMode  mode 
)

Get alpha color channel.

Gets the alpha color channel of type mode for the given color.

uint32_t alpha = leColorChannelAlpha(clr, mode);
Parameters
clris the source color value.
modeis the source color mode
Returns
the alpha color channel.

◆ leColorChannelBlue()

uint32_t leColorChannelBlue ( leColor  clr,
leColorMode  mode 
)

Get blue color channel.

Gets the blue color channel of type mode for the given color. leColor clr; leColorMode mode; uint32_t blue = leColorChannelBlue(clr, mode);

Parameters
modeis the colormode format.
nameis the name to query.
Returns
the blue color channel.

◆ leColorChannelGreen()

uint32_t leColorChannelGreen ( leColor  clr,
leColorMode  mode 
)

Get green color channel.

Gets the green color channel from color in the format mode.

leColor clr;
uint32_t green = leColorChannelGreen(clr, mode);

is the color to query. is the format.

Returns
the green color channel.

◆ leColorChannelRed()

uint32_t leColorChannelRed ( leColor  clr,
leColorMode  mode 
)

Get red color channel.

Gets the red color channel from color in the format mode.

leColor clr;
uint32_t red = leColorChannelRed(clr, mode);
Parameters
modeis the colormode required.
nameis the name to query
Returns
the red color channel

◆ leColorConvert()

leColor leColorConvert ( leColorMode  mode_in,
leColorMode  mode_out,
leColor  color 
)

Convert to color value.

Converts the color value of color from mode_in to mode_out.

leColorMode mode_in;
leColorName mode_out;
leColor color
leColor clr = leColorConvert(mode_in, mode_out, color);
Parameters
mode_inis the the source color.
mode_outis the source color mode.
coloris the color to convert.
Returns
the result color.

◆ leColorLerp()

leColor leColorLerp ( leColor  l,
leColor  r,
uint32_t  percent,
leColorMode  mode 
)

Get color from linear interpolate of two colors.

Gets a color from the linear interpolation of l and r with percentage of interpolation specified by percent and color format mode

leColor l;
leColor r;
uint32_t percent;
leColor blend = leColorLerp(l, r, percent, mode);
Parameters
foreis the foreground color.
backis the background color
Returns
the result color.
Here is the caller graph for this function:

◆ leColorSwap()

leColor leColorSwap ( leColor  clr,
leColorMode  mode 
)

Swaps the red and blue channels for a given color value.

Swaps the red and blue channels for a given color value. This can change an RGB color to BGR and vice versa.

Parameters
clris the color value.
modeis the color value mode.
Returns
the result color.

◆ leColorValue()

leColor leColorValue ( leColorMode  mode,
leColorName  name 
)

Get color by name and mode.

Gets a color by name in the format mode.

leColor color = leColorValue(mode, name);

is the colormode required. is the name to query

Returns
the color value of the given name in the specified format.

Variable Documentation

◆ leColorInfoTable

const leColorModeInfo leColorInfoTable[]

This array represents information reference table.

The reference table is used to hold color information.