GLIB - Graphics Library#

Silicon Labs Graphics Library.

Graphics Library

Silicon Labs Graphics Library. Feature rich graphics library for memory constrained applications.

Introduction#

GLIB is a graphics library that can be used to draw pixels, common shapes, text or bitmaps to a display connected to an MCU. The main goal of this library is easy of use and small code and memory footprint. In this way GLIB can be used on even the smallest Cortex-M0 devices.

GLIB treats the display as a matrix of pixels which is a model of the physical display. This matrix is exposed to GLIB via an API called DMD (Dot Matrix Display). So in order to draw something on a physical display the user application needs to provide GLIB with a single implementation of the DMD interface. Sample DMD implementations are provided for the displays that are connected to the Silicon Labs Starter Kits and the Silicon Labs Development Kits.

Initialization#

There are two things that must be initialized before GLIB can be used to draw pixels on the display. First the user needs to initialize the DMD implementation for the actual hardware display which is used. This initialization is display hardware specific.

After the DMD is initialized the user needs to initialize a GLIB_Context_t that can be used for all the drawing operations. A GLIB_Context_t structure is initialized using the GLIB_contextInit() function.

Every GLIB drawing function will require a GLIB_Context_t as one of the functions arguments. The GLIB context contains important configuration values that all the drawing functions use. It contains the foreground and background color, and it also contains information on what font to use when rendering text on the display.

Color#

GLIB represent color in a pixel as three 8 bit color values representing red, green and blue, giving the user support for a 24 bit color depth. The GLIB_rgbColor() function can be used to convert from distinct red, green and blue values to an 32-bit integer representing the color of single pixel. Similarly the GLIB_colorTranslate24bpp() function can be used to convert from the 32-bit integer representation into the 3 separate red, green and blue components. The 32-bit integer representation of a pixel color is used when configuring the foreground and background color.

GLIB also contains some common predefined colors for use in places where a 32-bit integer is used to represent the color. These predefined colors include White, Black, Brown, Orange, and many more. See the GLIB Colors for the full list of colors.

Some displays are monochrome, meaning that they only support 2 colors. When using GLIB to draw shapes on these displays the applications should use only the 2 colors White and Black.

Draw Shapes#

GLIB contains functions for drawing common shapes to a display. Here is a list containing all the drawing functions.

Draw Pixels#

These are functions that GLIB provides for drawing one pixel.

Font rendering#

GLIB Supports fixed width font rendering. The functions GLIB_drawString() and GLIB_drawChar() are used to render text on the display.

GLIB provides these fonts for the user

  • GLIB_FontNormal8x8 A normal 8x8 pixel font which is the default font if nothing else is configured.

  • GLIB_FontNarrow6x8 A narrow 6x8 pixel font which can be used if the default font is to wide.

  • GLIB_FontNumber16x20 A large font for use with only numbers. This font is 16x20 pixels.

To change the font the user calls GLIB_setFont() with a pointer to a GLIB_Font_t structure which describes the whole font. The GLIB_Font_t structure contains a pointer to the bitmap for each character and it describes attributes of the font like the width and height of each character and it also contains the bitmap of each character.

Draw Bitmap#

To draw an image or custom bitmaps on the display the GLIB_drawBitmap() function can be used. The color displays typically use a bitmap format where each pixel is represented by 3 consecutive bytes representing the red, green and blue color components. While monochrome displays typically use a bitmap format where 1 byte represents 8 pixels where a 1 bit is white and a 0 bit is black. Note that bitmaps are insensitive to the foreground and background color settings, and that the format of the bitmap depends on the DMD implementation of the display.

Example#

This examples shows how to initialize a GLIB context and draw something on a display.

static GLIB_Context_t context;
static const char * msg = "Hello GLIB!";

void glibExample(void)
{
  // Setup the dot matrix and initialize the GLIB context - these should be called once
  DMD_init(0);
  GLIB_contextInit(&context);

  // Write our message into the GLIB instance.
  GLIB_drawString(&context, msg, strlen(msg), 10, 10, true);

  // Needs to be called each time there is a change to GLIB to mirror
  // GLIB context data model changes to the physical LCD.
  DMD_updateDisplay();
}

Modules#

GLIB_Font_t

GLIB_Rectangle_t

GLIB_Context_t

DMD - Dot Matrix Display

GLIB BMP

GLIB Colors

Enumerations#

enum
InvalidFont = 0
FullFont
NumbersOnlyFont
}

Font classes.

enum
GLIB_ALIGN_LEFT
GLIB_ALIGN_CENTER
GLIB_ALIGN_RIGHT
}

Alignment types.

Functions#

EMSTATUS
GLIB_contextInit(GLIB_Context_t *pContext)

Define the default font.

EMSTATUS

Returns the display from sleep mode.

EMSTATUS

Sets the display in sleep mode.

EMSTATUS
GLIB_clear(GLIB_Context_t *pContext)

Clears the display with the background color of the GLIB_Context_t.

EMSTATUS
GLIB_clearRegion(const GLIB_Context_t *pContext)

Clears the clipping region by filling it with the background color of the GLIB_Context_t.

EMSTATUS
GLIB_resetDisplayClippingArea(GLIB_Context_t *pContext)

Reset the display driver clipping area to the whole display.

EMSTATUS
GLIB_resetClippingRegion(GLIB_Context_t *pContext)

Reset the GLIB_Context_t clipping region to the whole display.

EMSTATUS
GLIB_applyClippingRegion(const GLIB_Context_t *pContext)

Apply the clipping region from the GLIB_Context_t in the DMD driver.

void
GLIB_colorTranslate24bpp(uint32_t color, uint8_t *red, uint8_t *green, uint8_t *blue)

Extracts the color components from the 32-bit color passed and puts them in the passed in 8-bits ints.

uint32_t
GLIB_rgbColor(uint8_t red, uint8_t green, uint8_t blue)

Convert 3 uint8_t color components into a 24-bit color.

bool
GLIB_rectContainsPoint(const GLIB_Rectangle_t *pRect, int32_t xCenter, int32_t yCenter)

Checks if the point passed in is in the interior of the rectangle passed in.

void
GLIB_normalizeRect(GLIB_Rectangle_t *pRect)

Normalize the rectangle that is passed in.

EMSTATUS
GLIB_setClippingRegion(GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect)

Sets the clippingRegion of the passed in GLIB_Context_t.

EMSTATUS
GLIB_drawCircle(GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t radius)

Draws a circle with center at x, y, and a radius.

EMSTATUS
GLIB_drawCircleFilled(GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t radius)

Draws a filled circle with center at x, y, and a radius.

EMSTATUS
GLIB_drawPartialCircle(GLIB_Context_t *pContext, int32_t xCenter, int32_t yCenter, uint32_t radius, uint8_t bitMask)

Draws a partial circle with center at x, y, and a radius.

EMSTATUS
GLIB_setFont(GLIB_Context_t *pContext, GLIB_Font_t *pFont)

Set new font for the library.

EMSTATUS
GLIB_drawString(GLIB_Context_t *pContext, const char *pString, uint32_t sLength, int32_t x0, int32_t y0, bool opaque)

Draws a string using the font supplied with the library.

EMSTATUS
GLIB_drawStringOnLine(GLIB_Context_t *pContext, const char *pString, uint8_t line, GLIB_Align_t align, int32_t xOffset, int32_t yOffset, bool opaque)

Draws a string on the specified line on the display.

EMSTATUS
GLIB_drawChar(GLIB_Context_t *pContext, char myChar, int32_t x, int32_t y, bool opaque)

Draws a char using the font supplied with the library.

EMSTATUS
GLIB_drawBitmap(GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t width, uint32_t height, const uint8_t *picData)

Draws a bitmap.

void
GLIB_invertBitmap(GLIB_Context_t *pContext, uint32_t bitmapSize, uint8_t *picData)

Inverts each bit of the bitmap.

EMSTATUS
GLIB_drawLine(GLIB_Context_t *pContext, int32_t x1, int32_t y1, int32_t x2, int32_t y2)

Draws a line from x1,y1 to x2, y2.

EMSTATUS
GLIB_drawLineH(GLIB_Context_t *pContext, int32_t x1, int32_t y1, int32_t x2)

Draws a horizontal line from x1, y1 to x2, y2.

EMSTATUS
GLIB_drawLineV(GLIB_Context_t *pContext, int32_t x1, int32_t y1, int32_t y2)

Draws a vertical line from x1, y1 to x1, y2.

EMSTATUS
GLIB_drawRect(GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect)

Draws a rectangle outline defined by the passed in rectangle.

EMSTATUS
GLIB_drawRectFilled(GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect)

Draws a filled rectangle defined by the passed in rectangle.

EMSTATUS
GLIB_drawPolygon(GLIB_Context_t *pContext, uint32_t numPoints, const int32_t *polyPoints)

Draws a polygon using Bresnham's Midpoint Line Algorithm.

EMSTATUS
GLIB_drawPolygonFilled(GLIB_Context_t *pContext, uint32_t numPoints, const int32_t *polyPoints)

Draws a filled polygon using a scan line algorithm.

EMSTATUS
GLIB_drawPixelRGB(GLIB_Context_t *pContext, int32_t x, int32_t y, uint8_t red, uint8_t green, uint8_t blue)

Draws a pixel at x, y with color defined by red, green and blue 1 byte per channel.

EMSTATUS
GLIB_drawPixel(GLIB_Context_t *pContext, int32_t x, int32_t y)

Draws a pixel at x, y using foregroundColor defined in the GLIB_Context_t.

EMSTATUS
GLIB_drawPixelColor(GLIB_Context_t *pContext, int32_t x, int32_t y, uint32_t color)

Draws a pixel at x, y using the color parameter.

Macros#

#define
ECODE_GLIB_BASE 0x00000000

GLIB Base error code.

#define
GLIB_OK 0x00000000

Successful call.

#define
GLIB_ERROR_NOTHING_TO_DRAW (ECODE_GLIB_BASE | 0x0001)

Function did not draw.

#define
GLIB_ERROR_INVALID_CHAR (ECODE_GLIB_BASE | 0x0002)

Invalid char.

#define
GLIB_OUT_OF_BOUNDS (ECODE_GLIB_BASE | 0x0003)

Coordinates out of bounds.

#define
GLIB_ERROR_INVALID_CLIPPINGREGION (ECODE_GLIB_BASE | 0x0004)

Invalid coordinates (ex.

#define
GLIB_ERROR_INVALID_ARGUMENT (ECODE_GLIB_BASE | 0x0005)

Invalid argument.

#define
GLIB_ERROR_OUT_OF_MEMORY (ECODE_GLIB_BASE | 0x0006)

Out of memory.

#define
GLIB_ERROR_FILE_NOT_SUPPORTED (ECODE_GLIB_BASE | 0x0007)

File not supported.

#define
GLIB_ERROR_IO (ECODE_GLIB_BASE | 0x0008)

General IO Error.

#define
GLIB_ERROR_INVALID_FILE (ECODE_GLIB_BASE | 0x0009)

Invalid file.

Enumeration Documentation#

GLIB_Font_Class#

GLIB_Font_Class

Font classes.

Enumerator
InvalidFont

Invalid font.

FullFont

Characters and numbers font.

NumbersOnlyFont

Numbers only font.


Definition at line 230 of file platform/middleware/glib/glib/glib.h

GLIB_Align_t#

GLIB_Align_t

Alignment types.

Enumerator
GLIB_ALIGN_LEFT
GLIB_ALIGN_CENTER
GLIB_ALIGN_RIGHT

Definition at line 238 of file platform/middleware/glib/glib/glib.h

Function Documentation#

GLIB_contextInit#

EMSTATUS GLIB_contextInit (GLIB_Context_t * pContext)

Define the default font.

Parameters
N/ApContext

Pointer to a GLIB_Context_t

An application can override the default font by defining GLIB_NO_DEFAULT_FONT and by providing a custom GLIB_DEFAULT_FONT macro that points to a GLIB_Font_t structure that should be used as a default font.

Initialize the GLIB_Context_t

The context is set to default values and gets information about the display from the display driver.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 310 of file platform/middleware/glib/glib/glib.h

GLIB_displayWakeUp#

EMSTATUS GLIB_displayWakeUp (void )

Returns the display from sleep mode.

Parameters
N/A

Returns

  • Returns DMD_OK on success, or else error code


Definition at line 312 of file platform/middleware/glib/glib/glib.h

GLIB_displaySleep#

EMSTATUS GLIB_displaySleep (void )

Sets the display in sleep mode.

Parameters
N/A

Returns

  • Returns DMD_OK on success, or else error code


Definition at line 314 of file platform/middleware/glib/glib/glib.h

GLIB_clear#

EMSTATUS GLIB_clear (GLIB_Context_t * pContext)

Clears the display with the background color of the GLIB_Context_t.

Parameters
N/ApContext

Pointer to a GLIB_Context_t which holds the background color.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 316 of file platform/middleware/glib/glib/glib.h

GLIB_clearRegion#

EMSTATUS GLIB_clearRegion (const GLIB_Context_t * pContext)

Clears the clipping region by filling it with the background color of the GLIB_Context_t.

Parameters
N/ApContext

Pointer to a GLIB_Context_t which holds the background color.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 318 of file platform/middleware/glib/glib/glib.h

GLIB_resetDisplayClippingArea#

EMSTATUS GLIB_resetDisplayClippingArea (GLIB_Context_t * pContext)

Reset the display driver clipping area to the whole display.

Parameters
N/ApContext

Pointer to a GLIB_Context_t

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 320 of file platform/middleware/glib/glib/glib.h

GLIB_resetClippingRegion#

EMSTATUS GLIB_resetClippingRegion (GLIB_Context_t * pContext)

Reset the GLIB_Context_t clipping region to the whole display.

Parameters
N/ApContext

Pointer to a GLIB_Context_t

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 322 of file platform/middleware/glib/glib/glib.h

GLIB_applyClippingRegion#

EMSTATUS GLIB_applyClippingRegion (const GLIB_Context_t * pContext)

Apply the clipping region from the GLIB_Context_t in the DMD driver.

Parameters
N/ApContext

Pointer to a GLIB_Context_t

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 324 of file platform/middleware/glib/glib/glib.h

GLIB_colorTranslate24bpp#

void GLIB_colorTranslate24bpp (uint32_t color, uint8_t * red, uint8_t * green, uint8_t * blue)

Extracts the color components from the 32-bit color passed and puts them in the passed in 8-bits ints.

Parameters
N/Acolor

The color which is to be translated

N/Ared

Pointer to a uint8_t holding the red component

N/Agreen

Pointer to a uint8_t holding the green component

N/Ablue

Pointer to a uint8_t holding the blue component

The color is 24-bit RGB.

Example: color = 0x00FFFF00 -> red = 0xFF, green = 0xFF, blue = 0x00.


Definition at line 326 of file platform/middleware/glib/glib/glib.h

GLIB_rgbColor#

uint32_t GLIB_rgbColor (uint8_t red, uint8_t green, uint8_t blue)

Convert 3 uint8_t color components into a 24-bit color.

Parameters
N/Ared

Red component

N/Agreen

Green component

N/Ablue

Blue component

Example: red = 0xFF, green = 0xFF, blue = 0x00 -> 0x00FFFF00 = Yellow

Returns

  • Returns a 32-bit unsigned integer representing the color. The 8 LSB is blue, the next 8 is green and the next 8 is red. 0x00RRGGBB


Definition at line 328 of file platform/middleware/glib/glib/glib.h

GLIB_rectContainsPoint#

bool GLIB_rectContainsPoint (const GLIB_Rectangle_t * pRect, int32_t x, int32_t y)

Checks if the point passed in is in the interior of the rectangle passed in.

Parameters
N/ApRect

Pointer to a rectangle structure

N/Ax

X-coordinate of point

N/Ay

Y-coordinate of point

If the point is on the edge of the rectangle the function returns 1.

Returns

    • Returns false if coordinate is outside the rectangle

    • Returns true otherwise


Definition at line 330 of file platform/middleware/glib/glib/glib.h

GLIB_normalizeRect#

void GLIB_normalizeRect (GLIB_Rectangle_t * pRect)

Normalize the rectangle that is passed in.

Parameters
N/ApRect

Pointer to a rectangle structure

Sets yMin to the minimum value of yMin and yMax. Sets yMax to the maximum value of yMin and yMax. And the same for xMin and xMax


Definition at line 332 of file platform/middleware/glib/glib/glib.h

GLIB_setClippingRegion#

EMSTATUS GLIB_setClippingRegion (GLIB_Context_t * pContext, const GLIB_Rectangle_t * pRect)

Sets the clippingRegion of the passed in GLIB_Context_t.

Parameters
N/ApContext

Pointer to a GLIB_Context_t

N/ApRect

Pointer to a GLIB_Rectangle_t which is the clipping region to be set.

Returns

    • Returns GLIB_OK on success

    • Returns GLIB_ERROR_INVALID_CLIPPINGREGION if invalid coordinates

    • Returns GLIB_OUT_OF_BOUNDS if clipping region is bigger than display clipping area


Definition at line 334 of file platform/middleware/glib/glib/glib.h

GLIB_drawCircle#

EMSTATUS GLIB_drawCircle (GLIB_Context_t * pContext, int32_t xCenter, int32_t yCenter, uint32_t radius)

Draws a circle with center at x, y, and a radius.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color.

N/AxCenter

Center x-coordinate

N/AyCenter

Center y-coordinate

N/Aradius

Radius of the circle

Draws a circle using the Midpoint Circle Algorithm. See Wikipedia for algorithm. Algorithm is optimized to use only integer arithmetic, so no floating point arithmetic is needed.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 336 of file platform/middleware/glib/glib/glib.h

GLIB_drawCircleFilled#

EMSTATUS GLIB_drawCircleFilled (GLIB_Context_t * pContext, int32_t xCenter, int32_t yCenter, uint32_t radius)

Draws a filled circle with center at x, y, and a radius.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color.

N/AxCenter

Center x-coordinate

N/AyCenter

Center y-coordinate

N/Aradius

Radius of the circle

Draws a circle using the Midpoint Circle Algorithm and using horizontal lines. See Wikipedia for algorithm.

Returns

  • Returns GLIB_OK on succes. Returns GLIB_ERROR_NOTHING_TO_DRAW if none of the pixel coordinates were inside the clipping region. Returns error code otherwise.


Definition at line 339 of file platform/middleware/glib/glib/glib.h

GLIB_drawPartialCircle#

EMSTATUS GLIB_drawPartialCircle (GLIB_Context_t * pContext, int32_t xCenter, int32_t yCenter, uint32_t radius, uint8_t bitMask)

Draws a partial circle with center at x, y, and a radius.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color.

N/AxCenter

Center x-coordinate

N/AyCenter

Center y-coordinate

N/Aradius

Radius of the circle

N/AbitMask

Bitmask which decides which octants pixels should be drawn. The LSB is 1. octant, and the MSB is 8. octant.

Draws a partial circle using the Midpoint Circle Algorithm. Algorithm is optimized to use only integer arithmetic, so no floating point arithmetic is needed. The bitMask passed in decides which octant that should be drawn. The octants is numbered 1 to 8 in counterclockwise order.

Example: bitMask == 4 draws only pixels in 3. octant (00000100). bitMask == 5 draws only pixels in 3. and 1. octant (00000101).

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 342 of file platform/middleware/glib/glib/glib.h

GLIB_setFont#

EMSTATUS GLIB_setFont (GLIB_Context_t * pContext, GLIB_Font_t * pFont)

Set new font for the library.

Parameters
N/ApContext

Pointer to the GLIB_Context_t

N/ApFont

Pointer to the new font

Note that GLIB defines a default font in glib.c. Redefine GLIB_DEFAULT_FONT to change the default font.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 345 of file platform/middleware/glib/glib/glib.h

GLIB_drawString#

EMSTATUS GLIB_drawString (GLIB_Context_t * pContext, const char * pString, uint32_t sLength, int32_t x0, int32_t y0, bool opaque)

Draws a string using the font supplied with the library.

Parameters
N/ApContext

Pointer to a GLIB_Context_t

N/ApString

Pointer to the string that is drawn

N/AsLength

number of characters in the string

N/Ax0

Start x-coordinate for the string (Upper left corner)

N/Ay0

Start y-coordinate for the string (Upper left corner)

N/Aopaque

Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == 1, the background color is used.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 347 of file platform/middleware/glib/glib/glib.h

GLIB_drawStringOnLine#

EMSTATUS GLIB_drawStringOnLine (GLIB_Context_t * pContext, const char * pString, uint8_t line, GLIB_Align_t align, int32_t xOffset, int32_t yOffset, bool opaque)

Draws a string on the specified line on the display.

Parameters
N/ApContext

Pointer to a GLIB_Context_t

N/ApString

Pointer to the string that is drawn

N/Aline

Specifies which line on the display to draw on.

N/Aalign

Horizontal alignment of the string on the line. This can be left, right or center. Note that left alignment is default.

N/AxOffset

This parameter can be used to create a margin on the left or right side of the string. Note that this argument accepts a negative value which can be useful when aligning the string to the right.

N/AyOffset

This parameter can be used to move the string further down or up a certain number of pixels. A positive value would move the string down, while a negative value would move the string up.

N/Aopaque

Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == 1, the background color is used.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 350 of file platform/middleware/glib/glib/glib.h

GLIB_drawChar#

EMSTATUS GLIB_drawChar (GLIB_Context_t * pContext, char myChar, int32_t x, int32_t y, bool opaque)

Draws a char using the font supplied with the library.

Parameters
N/ApContext

Pointer to the GLIB_Context_t

N/AmyChar

Char to be drawn

N/Ax

Start x-coordinate for the char (Upper left corner)

N/Ay

Start y-coordinate for the char (Upper left corner)

N/Aopaque

Determines whether to show the background or color it with the background color specified by the GLIB_Context_t. If opaque == true, the background color is used.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 353 of file platform/middleware/glib/glib/glib.h

GLIB_drawBitmap#

EMSTATUS GLIB_drawBitmap (GLIB_Context_t * pContext, int32_t x, int32_t y, uint32_t width, uint32_t height, const uint8_t * picData)

Draws a bitmap.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the bitmap is drawn.

N/Ax

Start x-coordinate for bitmap

N/Ay

Start y-coordinate for bitmap

N/Awidth

Width of picture

N/Aheight

Height of picture

N/ApicData

Bitmap data

Sets up a bitmap that starts at x0,y0 and draws bitmap.

For monochrome displays, each 8-bit element contains 8 pixel values. A bit value of 1 indicates a white pixel, while 0 indicates a black pixel. Note that this format may vary with the DMD implementation.

For 3-bit RGB displays, each bit in the array are one color component (red, green and blue) of the pixel, so that 3 bits represent one pixel (0xBGR). Pixel 0: Bits 2:0 (0bBGR) of byte 0 Pixel 1: Bits 5:3 (0bBGR) of byte 0 Pixel 2: Bits 7:6 (0bGR) of byte 0 and bit 0 (0bB) of byte 1 Pixel 3: Bits 3:1 (0bBGR) of byte 1 ...

For RGB displays with 8-bits per color, each pixel is represented by 24-bits, with one byte for each of the red, green and blue components. The data has to be organized like this: picData = { R, G, B, R, G, B, R, G, B ... }

The pixels are ordered by increasing x coordinate, after the last pixel of a row, the next pixel will be the first pixel on the next row.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 356 of file platform/middleware/glib/glib/glib.h

GLIB_invertBitmap#

void GLIB_invertBitmap (GLIB_Context_t * pContext, uint32_t bitmapSize, uint8_t * picData)

Inverts each bit of the bitmap.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the bitmap is drawn.

N/AbitmapSize

Size of the bitmap array in terms of bytes.

N/ApicData

Bitmap data.

For monochrome displays, the result is an inversion of the image.

For RGB displays, the result is the negative of the input image.

Note

  • The function inverts entire bytes, meaning that any bits contained within the array that may not be part of the image will also be inverted.


Definition at line 359 of file platform/middleware/glib/glib/glib.h

GLIB_drawLine#

EMSTATUS GLIB_drawLine (GLIB_Context_t * pContext, int32_t x1, int32_t y1, int32_t x2, int32_t y2)

Draws a line from x1,y1 to x2, y2.

Parameters
N/ApContext

Pointer to the GLIB_Context_t which holds the clipping region

N/Ax1

Start x-coordinate

N/Ay1

Start y-coordinate

N/Ax2

End x-coordinate

N/Ay2

End y-coordinate

Draws a straight line using the Bresnham's Midpoint Line Algorithm. Checks for vertical and horizontal line.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 362 of file platform/middleware/glib/glib/glib.h

GLIB_drawLineH#

EMSTATUS GLIB_drawLineH (GLIB_Context_t * pContext, int32_t x1, int32_t y1, int32_t x2)

Draws a horizontal line from x1, y1 to x2, y2.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the line is drawn. The line is drawn using the foreground color.

N/Ax1

Start x-coordinate

N/Ay1

Start y-coordinate

N/Ax2

End x-coordinate

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 365 of file platform/middleware/glib/glib/glib.h

GLIB_drawLineV#

EMSTATUS GLIB_drawLineV (GLIB_Context_t * pContext, int32_t x1, int32_t y1, int32_t y2)

Draws a vertical line from x1, y1 to x1, y2.

Parameters
N/ApContext

Pointer to a GLIB_Context_t which the line is drawn. The line is drawn using the foreground color.

N/Ax1

Start x-coordinate

N/Ay1

Start y-coordinate

N/Ay2

End y-coordinate

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 368 of file platform/middleware/glib/glib/glib.h

GLIB_drawRect#

EMSTATUS GLIB_drawRect (GLIB_Context_t * pContext, const GLIB_Rectangle_t * pRect)

Draws a rectangle outline defined by the passed in rectangle.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is drawn using the foreground color.

N/ApRect

Pointer to a rectangle structure

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 371 of file platform/middleware/glib/glib/glib.h

GLIB_drawRectFilled#

EMSTATUS GLIB_drawRectFilled (GLIB_Context_t * pContext, const GLIB_Rectangle_t * pRect)

Draws a filled rectangle defined by the passed in rectangle.

Parameters
N/ApContext

Pointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is filled with the foreground color.

N/ApRect

Pointer to a rectangle structure

The filled rectangle is drawn from (xMin, yMin) to (xMax, yMax), inclusive, of the rectangle passed in.

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 373 of file platform/middleware/glib/glib/glib.h

GLIB_drawPolygon#

EMSTATUS GLIB_drawPolygon (GLIB_Context_t * pContext, uint32_t numPoints, const int32_t * polyPoints)

Draws a polygon using Bresnham's Midpoint Line Algorithm.

Parameters
N/ApContext

Pointer to a GLIB_Context_t which the line is drawn. The lines are drawn using the foreground color.

N/AnumPoints

Number of points in the polygon ( Has to be greater than 1 )

N/ApolyPoints

Pointer to array of polygon points. The points are laid out like this: polyPoints = {x1,y1,x2,y2 ... } Polypoints has to contain at least (numPoints * 2) entries

This function draws a line between all points outlining the polygon. The first and last point doesn't have to be the same. The function automatically draws a line from the start point to the end point.

Returns

  • Returns GLIB_OK on if at least one element was drawn, or else error code


Definition at line 376 of file platform/middleware/glib/glib/glib.h

GLIB_drawPolygonFilled#

EMSTATUS GLIB_drawPolygonFilled (GLIB_Context_t * pContext, uint32_t numPoints, const int32_t * polyPoints)

Draws a filled polygon using a scan line algorithm.

Parameters
N/ApContext

Pointer to a GLIB_Context_t where the polygon is drawn. The polygon drawn using the foreground color.

N/AnumPoints

Number of points in the polygon ( Has to be greater than 1 )

N/ApolyPoints

Pointer to array of polygon points. The points are laid out like this: polyPoints = {x1,y1,x2,y2 ... } Polypoints has to contain at least (numPoints * 2) entries

This function draws a line between all points outlining the polygon. The first and last point doesn't have to be the same. The function automatically draws a line from the start point to the end point.

Returns

  • Returns GLIB_OK on success, otherwise a GLIB error code.


Definition at line 379 of file platform/middleware/glib/glib/glib.h

GLIB_drawPixelRGB#

EMSTATUS GLIB_drawPixelRGB (GLIB_Context_t * pContext, int32_t x, int32_t y, uint8_t red, uint8_t green, uint8_t blue)

Draws a pixel at x, y with color defined by red, green and blue 1 byte per channel.

Parameters
N/ApContext

Pointer to a GLIB_Context_t which holds the clipping region

N/Ax

X-coordinate

N/Ay

Y-coordinate

N/Ared

8-bit red code

N/Agreen

8-bit green code

N/Ablue

8-bit blue code

Example: To draw a yellow pixel at (10, 10). x = 10, y = 10, red = 0xFF, green = 0xFF, blue = 0x00

Returns

  • Returns DMD_OK on success, or else error code


Definition at line 382 of file platform/middleware/glib/glib/glib.h

GLIB_drawPixel#

EMSTATUS GLIB_drawPixel (GLIB_Context_t * pContext, int32_t x, int32_t y)

Draws a pixel at x, y using foregroundColor defined in the GLIB_Context_t.

Parameters
N/ApContext

Pointer to a GLIB_Context_t which holds the foreground color and clipping region

N/Ax

X-coordinate

N/Ay

Y-coordinate

Returns

  • Returns GLIB_OK on success, or else error code


Definition at line 385 of file platform/middleware/glib/glib/glib.h

GLIB_drawPixelColor#

EMSTATUS GLIB_drawPixelColor (GLIB_Context_t * pContext, int32_t x, int32_t y, uint32_t color)

Draws a pixel at x, y using the color parameter.

Parameters
N/ApContext

Pointer to a GLIB_Context_t which holds the clipping region

N/Ax

X-coordinate

N/Ay

Y-coordinate

N/Acolor

32-bit int defining the RGB color. The 24 LSB defines the RGB color like this: RRRRRRRRGGGGGGGGBBBBBBBB. Example: Yellow = 0x00FFFF00

Returns

  • Returns DMD_OK on success, or else error code


Definition at line 387 of file platform/middleware/glib/glib/glib.h

Macro Definition Documentation#

ECODE_GLIB_BASE#

#define ECODE_GLIB_BASE
Value:
0x00000000

GLIB Base error code.


Definition at line 204 of file platform/middleware/glib/glib/glib.h

GLIB_OK#

#define GLIB_OK
Value:
0x00000000

Successful call.


Definition at line 208 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_NOTHING_TO_DRAW#

#define GLIB_ERROR_NOTHING_TO_DRAW
Value:
(ECODE_GLIB_BASE | 0x0001)

Function did not draw.


Definition at line 210 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_INVALID_CHAR#

#define GLIB_ERROR_INVALID_CHAR
Value:
(ECODE_GLIB_BASE | 0x0002)

Invalid char.


Definition at line 212 of file platform/middleware/glib/glib/glib.h

GLIB_OUT_OF_BOUNDS#

#define GLIB_OUT_OF_BOUNDS
Value:
(ECODE_GLIB_BASE | 0x0003)

Coordinates out of bounds.


Definition at line 214 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_INVALID_CLIPPINGREGION#

#define GLIB_ERROR_INVALID_CLIPPINGREGION
Value:
(ECODE_GLIB_BASE | 0x0004)

Invalid coordinates (ex.

xMin > xMax)


Definition at line 216 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_INVALID_ARGUMENT#

#define GLIB_ERROR_INVALID_ARGUMENT
Value:
(ECODE_GLIB_BASE | 0x0005)

Invalid argument.


Definition at line 218 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_OUT_OF_MEMORY#

#define GLIB_ERROR_OUT_OF_MEMORY
Value:
(ECODE_GLIB_BASE | 0x0006)

Out of memory.


Definition at line 220 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_FILE_NOT_SUPPORTED#

#define GLIB_ERROR_FILE_NOT_SUPPORTED
Value:
(ECODE_GLIB_BASE | 0x0007)

File not supported.


Definition at line 222 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_IO#

#define GLIB_ERROR_IO
Value:
(ECODE_GLIB_BASE | 0x0008)

General IO Error.


Definition at line 224 of file platform/middleware/glib/glib/glib.h

GLIB_ERROR_INVALID_FILE#

#define GLIB_ERROR_INVALID_FILE
Value:
(ECODE_GLIB_BASE | 0x0009)

Invalid file.


Definition at line 226 of file platform/middleware/glib/glib/glib.h

GLIB_NO_DEFAULT_FONT#

#define GLIB_NO_DEFAULT_FONT

Definition at line 394 of file platform/middleware/glib/glib/glib.h