EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2

Detailed Description

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 Silion 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 GBLI 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_color.h file 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

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. Note that the format of the bitmap depends on the DMD implementation of the display. 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 a monochrome display typically use a bitmap format where 1 byte represents 8 pixels where a 0 bit is white and a 1 bit is black.


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 setupGlib(void)
{
DMD_init(0);
GLIB_contextInit(&context);
GLIB_drawString(&context, msg, strlen(msg), 10, 10, true);
}

Data Structures

struct  __BMP_DataType
 BMP Data type structure to hold information about the bmp data returned. More...
 
struct  __BMP_Header
 BMP Module header structure. Must be packed to exact 54 bytes. More...
 
struct  __BMP_Palette
 BMP palette structure to hold palette pointer and size. More...
 
struct  __GLIB_Context_t
 GLIB Drawing Context (Multiple instances of GLIB_Context_t can exist) More...
 
struct  __GLIB_Font_t
 Font definition structure. More...
 
struct  __GLIB_Rectangle_t
 Rectangle structure. More...
 

Macros

#define BMP_END_OF_FILE
 
#define BMP_ERROR_BUFFER_TOO_SMALL   (ECODE_BMP_BASE | 0x0020)
 
#define BMP_ERROR_END_OF_FILE   (ECODE_BMP_BASE | 0x0010)
 
#define BMP_ERROR_ENDIAN_MISMATCH   (ECODE_BMP_BASE | 0x0003)
 
#define BMP_ERROR_FILE_INVALID   (ECODE_BMP_BASE | 0x0005)
 
#define BMP_ERROR_FILE_NOT_RESET   (ECODE_BMP_BASE | 0x0009)
 
#define BMP_ERROR_FILE_NOT_SUPPORTED   (ECODE_BMP_BASE | 0x0004)
 
#define BMP_ERROR_HEADER_SIZE_MISMATCH   (ECODE_BMP_BASE | 0x0002)
 
#define BMP_ERROR_INVALID_ARGUMENT   (ECODE_BMP_BASE | 0x0006)
 
#define BMP_ERROR_INVALID_PALETTE_SIZE   (ECODE_BMP_BASE | 0x0008)
 
#define BMP_ERROR_IO   (ECODE_BMP_BASE | 0x0001)
 
#define BMP_ERROR_MODULE_NOT_INITIALIZED   (ECODE_BMP_BASE | 0x0007)
 
#define BMP_ERROR_PALETTE_NOT_READ   (ECODE_BMP_BASE | 0x0030)
 
#define BMP_HEADER_SIZE   (54)
 
#define BMP_LOCAL_CACHE_LIMIT   (3)
 
#define BMP_LOCAL_CACHE_SIZE   (BMP_CONFIG_LOCAL_CACHE_SIZE)
 
#define BMP_OK   0x00000000
 
#define BMP_PALETTE_8BIT_SIZE   (256 * 4)
 
#define ECODE_BMP_BASE   0x00000000
 
#define ECODE_GLIB_BASE   0x00000000
 
#define GLIB_ERROR_FILE_NOT_SUPPORTED   (ECODE_GLIB_BASE | 0x0007)
 
#define GLIB_ERROR_INVALID_ARGUMENT   (ECODE_GLIB_BASE | 0x0005)
 
#define GLIB_ERROR_INVALID_CHAR   (ECODE_GLIB_BASE | 0x0002)
 
#define GLIB_ERROR_INVALID_CLIPPINGREGION   (ECODE_GLIB_BASE | 0x0004)
 
#define GLIB_ERROR_INVALID_FILE   (ECODE_GLIB_BASE | 0x0009)
 
#define GLIB_ERROR_IO   (ECODE_GLIB_BASE | 0x0008)
 
#define GLIB_ERROR_NOTHING_TO_DRAW   (ECODE_GLIB_BASE | 0x0001)
 
#define GLIB_ERROR_OUT_OF_MEMORY   (ECODE_GLIB_BASE | 0x0006)
 
#define GLIB_OK   0x00000000
 
#define GLIB_OUT_OF_BOUNDS   (ECODE_GLIB_BASE | 0x0003)
 
#define NO_COMPRESSION   (0)
 
#define RLE8_COMPRESSION   (1)
 

Typedefs

typedef struct __BMP_DataType BMP_DataType
 BMP Data type structure to hold information about the bmp data returned.
 
typedef struct __BMP_Header BMP_Header
 
typedef struct __BMP_Palette BMP_Palette
 BMP palette structure to hold palette pointer and size.
 
typedef struct __GLIB_Context_t GLIB_Context_t
 GLIB Drawing Context (Multiple instances of GLIB_Context_t can exist)
 
typedef enum __GLIB_Font_Class GLIB_Font_Class
 Font classes.
 
typedef struct __GLIB_Font_t GLIB_Font_t
 Font definition structure.
 
typedef struct __GLIB_Rectangle_t GLIB_Rectangle_t
 Rectangle structure.
 

Enumerations

enum  __GLIB_Font_Class {
  InvalidFont = 0,
  FullFont,
  NumbersOnlyFont
}
 Font classes. More...
 

Functions

int16_t BMP_getBitsPerPixel (void)
 Get color depth (bits per pixel) More...
 
int32_t BMP_getCompressionType (void)
 Get compression type. More...
 
int32_t BMP_getDataOffset (void)
 Get the offset, i.e. starting address, of the byte where the bitmap data can be found. More...
 
int32_t BMP_getFileSize (void)
 Get the fileSize in bytes. More...
 
int32_t BMP_getHeight (void)
 Get height of BMP image in pixels. More...
 
int32_t BMP_getImageDataSize (void)
 Get imageDataSize in bytes. More...
 
int32_t BMP_getWidth (void)
 Get width of BMP image in pixels. More...
 
EMSTATUS BMP_init (uint8_t *palette, uint32_t paletteSize, EMSTATUS(*fp)(uint8_t buffer[], uint32_t bufLength, uint32_t bytesToRead))
 Initializes BMP Module. More...
 
EMSTATUS BMP_readRawData (BMP_DataType *dataType, uint8_t buffer[], uint32_t bufLength)
 Fills buffer with raw data from BMP file. More...
 
EMSTATUS BMP_readRgbData (uint8_t buffer[], uint32_t bufLength, uint32_t *pixelsRead)
 Reads in data from BMP file and fills buffer with RGB values. This function terminates either when the buffer is full, end of row is reached or end of file is reached. More...
 
EMSTATUS BMP_reset (void)
 Makes the module ready for new bmp file. Reads in header from file, and checks if the provided bmp file is valid and supported. It reads in palette if BMP file is 8bpp. Uses function pointer set in BMP_init(). More...
 
EMSTATUS GLIB_applyClippingRegion (const GLIB_Context_t *pContext)
 Apply the clipping region from the GLIB_Context_t in the DMD driver. More...
 
EMSTATUS GLIB_clear (GLIB_Context_t *pContext)
 Clears the display with the background color of the GLIB_Context_t. More...
 
EMSTATUS GLIB_clearRegion (const GLIB_Context_t *pContext)
 Clears the clipping region by filling it with the background color of the GLIB_Context_t. More...
 
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. The color is 24-bit RGB. More...
 
EMSTATUS GLIB_contextInit (GLIB_Context_t *pContext)
 Initialize the GLIB_Context_t. More...
 
EMSTATUS GLIB_displaySleep (void)
 Sets the display in sleep mode. More...
 
EMSTATUS GLIB_displayWakeUp (void)
 Returns the display from sleep mode. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
EMSTATUS GLIB_drawPolygon (GLIB_Context_t *pContext, uint32_t numPoints, const int32_t *polyPoints)
 Draws a polygon using Bresnham's Midpoint Line Algorithm. More...
 
EMSTATUS GLIB_drawRect (GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect)
 Draws a rectangle outline defined by the passed in rectangle. More...
 
EMSTATUS GLIB_drawRectFilled (GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect)
 Draws a filled rectangle defined by the passed in rectangle. The filled rectangle is drawn from (xMin, yMin) to (xMax, yMax), inclusive, of the rectangle passed in. More...
 
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. More...
 
void GLIB_normalizeRect (GLIB_Rectangle_t *pRect)
 Normalize the rectangle that is passed in. 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. More...
 
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. More...
 
EMSTATUS GLIB_resetClippingRegion (GLIB_Context_t *pContext)
 Reset the GLIB_Context_t clipping region to the whole display. More...
 
EMSTATUS GLIB_resetDisplayClippingArea (GLIB_Context_t *pContext)
 Reset the display driver clipping area to the whole display. More...
 
uint32_t GLIB_rgbColor (uint8_t red, uint8_t green, uint8_t blue)
 Convert 3 uint8_t color components into a 24-bit color. More...
 
EMSTATUS GLIB_setClippingRegion (GLIB_Context_t *pContext, const GLIB_Rectangle_t *pRect)
 Sets the clippingRegion of the passed in GLIB_Context_t. More...
 
EMSTATUS GLIB_setFont (GLIB_Context_t *pContext, GLIB_Font_t *pFont)
 Set new font for the library. Note that GLIB defines a default font in glib.c. Redefine GLIB_DEFAULT_FONT to change the default font. More...
 

Variables

const GLIB_Font_t GLIB_FontNarrow6x8
 Narrow 6x8 pixels font containing characters and numbers.
 
const GLIB_Font_t GLIB_FontNormal8x8
 Normal 8x8 pixels font containing characters and numbers.
 
const GLIB_Font_t GLIB_FontNumber16x20
 Large 16x20 pixels font containing only numbers.
 

Macro Definition Documentation

#define BMP_END_OF_FILE

End of file has been reached

Definition at line 40 of file bmp.h.

#define BMP_ERROR_BUFFER_TOO_SMALL   (ECODE_BMP_BASE | 0x0020)

Buffer provided is too small

Definition at line 62 of file bmp.h.

Referenced by BMP_init(), and BMP_readRgbData().

#define BMP_ERROR_END_OF_FILE   (ECODE_BMP_BASE | 0x0010)

End of bmp file is reached

Definition at line 60 of file bmp.h.

Referenced by BMP_readRawData(), and BMP_readRgbData().

#define BMP_ERROR_ENDIAN_MISMATCH   (ECODE_BMP_BASE | 0x0003)

Endian mismatch

Definition at line 46 of file bmp.h.

Referenced by BMP_reset().

#define BMP_ERROR_FILE_INVALID   (ECODE_BMP_BASE | 0x0005)

BMP "file" is not a BMP file

Definition at line 50 of file bmp.h.

Referenced by BMP_reset().

#define BMP_ERROR_FILE_NOT_RESET   (ECODE_BMP_BASE | 0x0009)

File not reset. Call BMP_reset()

Definition at line 58 of file bmp.h.

Referenced by BMP_readRawData(), and BMP_readRgbData().

#define BMP_ERROR_FILE_NOT_SUPPORTED   (ECODE_BMP_BASE | 0x0004)

BMP file is not supported

Definition at line 48 of file bmp.h.

Referenced by BMP_reset().

#define BMP_ERROR_HEADER_SIZE_MISMATCH   (ECODE_BMP_BASE | 0x0002)

BMP_Header size in bytes is different from BMP_HEADER_SIZE

Definition at line 44 of file bmp.h.

Referenced by BMP_init().

#define BMP_ERROR_INVALID_ARGUMENT   (ECODE_BMP_BASE | 0x0006)

Argument passed to function is invalid

Definition at line 52 of file bmp.h.

Referenced by BMP_readRawData().

#define BMP_ERROR_INVALID_PALETTE_SIZE   (ECODE_BMP_BASE | 0x0008)

Invalid palette size

Definition at line 56 of file bmp.h.

Referenced by BMP_reset().

#define BMP_ERROR_IO   (ECODE_BMP_BASE | 0x0001)

General IO error

Definition at line 42 of file bmp.h.

#define BMP_ERROR_MODULE_NOT_INITIALIZED   (ECODE_BMP_BASE | 0x0007)

BMP module is not initialized. Call BMP_init()

Definition at line 54 of file bmp.h.

Referenced by BMP_readRawData(), BMP_readRgbData(), and BMP_reset().

#define BMP_ERROR_PALETTE_NOT_READ   (ECODE_BMP_BASE | 0x0030)

Bmp palette is not read

Definition at line 64 of file bmp.h.

Referenced by BMP_readRawData(), BMP_readRgbData(), and BMP_reset().

#define BMP_HEADER_SIZE   (54)

BMP Header Size in bytes

Definition at line 69 of file bmp.h.

Referenced by BMP_init(), and BMP_reset().

#define BMP_LOCAL_CACHE_LIMIT   (3)

BMP Local cache limit

Definition at line 71 of file bmp.h.

Referenced by BMP_init().

#define BMP_LOCAL_CACHE_SIZE   (BMP_CONFIG_LOCAL_CACHE_SIZE)

BMP Local cache size

Definition at line 79 of file bmp.h.

Referenced by BMP_init(), and BMP_readRgbData().

#define BMP_OK   0x00000000

Successful call

Definition at line 38 of file bmp.h.

Referenced by BMP_getPressure(), BMP_getTemperature(), BMP_init(), BMP_readRawData(), BMP_readRgbData(), and BMP_reset().

#define BMP_PALETTE_8BIT_SIZE   (256 * 4)

Palette size in bytes

Definition at line 67 of file bmp.h.

#define ECODE_BMP_BASE   0x00000000

BMP base error code

Definition at line 34 of file bmp.h.

#define ECODE_GLIB_BASE   0x00000000

GLIB Base error code

Definition at line 186 of file glib.h.

#define GLIB_ERROR_FILE_NOT_SUPPORTED   (ECODE_GLIB_BASE | 0x0007)

File not supported

Definition at line 204 of file glib.h.

#define GLIB_ERROR_INVALID_CHAR   (ECODE_GLIB_BASE | 0x0002)

Invalid char

Definition at line 194 of file glib.h.

Referenced by GLIB_drawChar(), and GLIB_drawString().

#define GLIB_ERROR_INVALID_CLIPPINGREGION   (ECODE_GLIB_BASE | 0x0004)

Invalid coordinates (ex. xMin > xMax)

Definition at line 198 of file glib.h.

Referenced by GLIB_setClippingRegion().

#define GLIB_ERROR_INVALID_FILE   (ECODE_GLIB_BASE | 0x0009)

Invalid file

Definition at line 208 of file glib.h.

#define GLIB_ERROR_IO   (ECODE_GLIB_BASE | 0x0008)

General IO Error

Definition at line 206 of file glib.h.

#define GLIB_ERROR_OUT_OF_MEMORY   (ECODE_GLIB_BASE | 0x0006)

Out of memory

Definition at line 202 of file glib.h.

#define GLIB_OUT_OF_BOUNDS   (ECODE_GLIB_BASE | 0x0003)

Coordinates out of bounds

Definition at line 196 of file glib.h.

Referenced by GLIB_setClippingRegion().

#define NO_COMPRESSION   (0)

Use no compression

Definition at line 76 of file bmp.h.

Referenced by BMP_readRawData(), and BMP_readRgbData().

#define RLE8_COMPRESSION   (1)

Use RLE8 compression

Definition at line 74 of file bmp.h.

Referenced by BMP_readRawData(), and BMP_readRgbData().

Enumeration Type Documentation

Font classes.

Enumerator
InvalidFont 

Invalid font.

FullFont 

Characters and numbers font.

NumbersOnlyFont 

Numbers only font.

Definition at line 213 of file glib.h.

Function Documentation

int16_t BMP_getBitsPerPixel ( void  )

Get color depth (bits per pixel)

Returns
Returns bitsPerPixel, or -1 on error

Definition at line 952 of file bmp.c.

References __BMP_Header::bitsPerPixel.

int32_t BMP_getCompressionType ( void  )

Get compression type.

0 - No compression 1 - RLE 8bpp 2 - RLE 4bpp

Returns
Returns compressionType, or -1 on error

Definition at line 970 of file bmp.c.

References __BMP_Header::compressionType.

int32_t BMP_getDataOffset ( void  )

Get the offset, i.e. starting address, of the byte where the bitmap data can be found.

Returns
Returns dataOffset, or -1 on error

Definition at line 998 of file bmp.c.

References __BMP_Header::dataOffset.

int32_t BMP_getFileSize ( void  )

Get the fileSize in bytes.

Returns
Returns fileSize, or -1 on error

Definition at line 1012 of file bmp.c.

References __BMP_Header::fileSize.

int32_t BMP_getHeight ( void  )

Get height of BMP image in pixels.

Returns
Returns height, or -1 on error

Definition at line 938 of file bmp.c.

References __BMP_Header::height.

int32_t BMP_getImageDataSize ( void  )

Get imageDataSize in bytes.

Returns
Returns imageDataSize, or -1 on error

Definition at line 984 of file bmp.c.

References __BMP_Header::imageDataSize.

int32_t BMP_getWidth ( void  )

Get width of BMP image in pixels.

Returns
Returns width of image, or -1 on error

Definition at line 924 of file bmp.c.

References __BMP_Header::width.

EMSTATUS BMP_init ( uint8_t *  palette,
uint32_t  paletteSize,
EMSTATUS(*)(uint8_t buffer[], uint32_t bufLength, uint32_t bytesToRead)  fp 
)

Initializes BMP Module.

Support:

  • 24-bit Uncompressed.
  • 8-bit Uncompressed.
  • 8-bit RLE compressed.
Parameters
paletteData buffer to hold palette. Required for 8bpp BMPs.
paletteSizeSize of palette in bytes. If BMP is 8-bit, this potentially has to be 256 * 4 bytes. If the user knows that he only loads BMPs with N bytes, he can pass in paletteSize = N. Otherwise this value should be 256 * 4 = 1024 bytes to ensure that the palette is big enough for all 8-bits BMPs.
fpFunction pointer that is used to read in bytes from BMP file. The function has to return an EMSTATUS and have the following parameter list (uint32_t buffer[], uint32_t bufLength, uint32_t bytesToRead). The function should fill (buffer) with (bytesToRead) bytes from the beginning. If it succeds it has to return BMP_OK, otherwise it should return BMP_ERROR_IO. When the function returns it should be ready to read from where it left off.
Returns
Returns BMP_OK on success, or else error code.

Definition at line 99 of file bmp.c.

References BMP_ERROR_BUFFER_TOO_SMALL, BMP_ERROR_HEADER_SIZE_MISMATCH, BMP_HEADER_SIZE, BMP_LOCAL_CACHE_LIMIT, BMP_LOCAL_CACHE_SIZE, BMP_OK, __BMP_Palette::data, and __BMP_Palette::size.

EMSTATUS BMP_readRawData ( BMP_DataType dataType,
uint8_t  buffer[],
uint32_t  bufLength 
)

Fills buffer with raw data from BMP file.

  • If data is 24bit: Buffer is filled with RGB values till its full or end of row is reached.
  • If data is 8bit: Buffer is filled with palette indicies till its full or end of row is reached.
  • If data is RLE8: Buffer is filled with number of pixels, followed by palette indicies like this (N is number of pixels, P is palette index) buffer = { N P N P ... }.
  • Data is 24bpp if dataType.bitsPerPixel == 24 and dataType.compressionType == NO_COMPRESSION.
  • Data is 8bpp if dataType.bitsPerPixel == 8 and dataType.compressionType == NO_COMPRESSION.
  • Data is RLE8 if dataType.bitsPerPixel == 8 and dataType.compressionType == RLE8_COMPRESSION.
Parameters
dataTypeData type struct which holds information about the data returned
bufferBuffer to be filled with raw data
bufLengthLength of buffer
Returns
Returns BMP_OK on success, or else error code

Definition at line 850 of file bmp.c.

References __BMP_Header::bitsPerPixel, __BMP_DataType::bitsPerPixel, BMP_ERROR_END_OF_FILE, BMP_ERROR_FILE_NOT_RESET, BMP_ERROR_INVALID_ARGUMENT, BMP_ERROR_MODULE_NOT_INITIALIZED, BMP_ERROR_PALETTE_NOT_READ, BMP_OK, __BMP_Header::compressionType, __BMP_DataType::compressionType, __BMP_DataType::endOfRow, __BMP_Header::height, __BMP_Header::imageDataSize, NO_COMPRESSION, RLE8_COMPRESSION, __BMP_DataType::size, and __BMP_Header::width.

Referenced by BMP_readRgbData().

EMSTATUS BMP_readRgbData ( uint8_t  buffer[],
uint32_t  bufLength,
uint32_t *  pixelsRead 
)

Reads in data from BMP file and fills buffer with RGB values. This function terminates either when the buffer is full, end of row is reached or end of file is reached.

Parameters
bufferBuffer to hold RGB values.
bufLengthBuffer length in bytes.
pixelsReadPointer to a uint32_t which holds how many bytes that are read.
Returns
  • Returns BMP_OK on success
  • Returns BMP_ERROR_END_OF_FILE if end of file is reached
  • Returns error code otherwise.

Definition at line 247 of file bmp.c.

References __BMP_Header::bitsPerPixel, BMP_ERROR_BUFFER_TOO_SMALL, BMP_ERROR_END_OF_FILE, BMP_ERROR_FILE_NOT_RESET, BMP_ERROR_MODULE_NOT_INITIALIZED, BMP_ERROR_PALETTE_NOT_READ, BMP_LOCAL_CACHE_SIZE, BMP_OK, BMP_readRawData(), __BMP_Header::compressionType, __BMP_Palette::data, __BMP_DataType::endOfRow, __BMP_Header::height, __BMP_Header::imageDataSize, NO_COMPRESSION, RLE8_COMPRESSION, __BMP_DataType::size, and __BMP_Header::width.

EMSTATUS BMP_reset ( void  )

Makes the module ready for new bmp file. Reads in header from file, and checks if the provided bmp file is valid and supported. It reads in palette if BMP file is 8bpp. Uses function pointer set in BMP_init().

Returns
Returns BMP_OK on success, or else error code

Definition at line 131 of file bmp.c.

References __BMP_Header::bitsPerPixel, BMP_ERROR_ENDIAN_MISMATCH, BMP_ERROR_FILE_INVALID, BMP_ERROR_FILE_NOT_SUPPORTED, BMP_ERROR_INVALID_PALETTE_SIZE, BMP_ERROR_MODULE_NOT_INITIALIZED, BMP_ERROR_PALETTE_NOT_READ, BMP_HEADER_SIZE, BMP_OK, __BMP_Header::compressionType, __BMP_Palette::data, __BMP_Header::dataOffset, __BMP_Header::fileSize, __BMP_Header::headerSize, __BMP_Header::height, __BMP_Header::imageDataSize, __BMP_Header::magic, and __BMP_Palette::size.

EMSTATUS GLIB_applyClippingRegion ( const GLIB_Context_t pContext)

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

Parameters
pContextPointer to a GLIB_Context_t
Returns
Returns GLIB_OK on success, or else error code

Definition at line 278 of file glib.c.

References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

Referenced by GLIB_clearRegion(), GLIB_drawBitmap(), GLIB_drawLineH(), GLIB_drawLineV(), GLIB_drawRectFilled(), and GLIB_setClippingRegion().

EMSTATUS GLIB_clear ( GLIB_Context_t pContext)

Clears the display with the background color of the GLIB_Context_t.

Parameters
pContextPointer to a GLIB_Context_t which holds the background color.
Returns
Returns GLIB_OK on success, or else error code

Definition at line 163 of file glib.c.

References __GLIB_Context_t::backgroundColor, GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_OK, GLIB_resetDisplayClippingArea(), and __GLIB_Context_t::pDisplayGeometry.

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
pContextPointer to a GLIB_Context_t which holds the background color.
Returns
Returns GLIB_OK on success, or else error code

Definition at line 199 of file glib.c.

References __GLIB_Context_t::backgroundColor, __GLIB_Context_t::clippingRegion, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

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. The color is 24-bit RGB.

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

Parameters
colorThe color which is to be translated
redPointer to a uint8_t holding the red component
greenPointer to a uint8_t holding the green component
bluePointer to a uint8_t holding the blue component
Returns
None.

Definition at line 309 of file glib.c.

Referenced by GLIB_clear(), GLIB_clearRegion(), GLIB_drawLineH(), GLIB_drawLineV(), and GLIB_drawRectFilled().

EMSTATUS GLIB_contextInit ( GLIB_Context_t pContext)

Initialize the GLIB_Context_t.

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

Parameters
pContextPointer to a GLIB_Context_t
Returns
Returns GLIB_OK on success, or else error code

Definition at line 59 of file glib.c.

References __GLIB_Context_t::backgroundColor, Black, __GLIB_Context_t::foregroundColor, GLIB_DEFAULT_FONT, GLIB_ERROR_INVALID_ARGUMENT, GLIB_OK, GLIB_setClippingRegion(), GLIB_setFont(), __GLIB_Context_t::pDisplayGeometry, and White.

EMSTATUS GLIB_displaySleep ( void  )

Sets the display in sleep mode.

Returns
Returns DMD_OK on success, or else error code

Definition at line 110 of file glib.c.

EMSTATUS GLIB_displayWakeUp ( void  )

Returns the display from sleep mode.

Returns
Returns DMD_OK on success, or else error code

Definition at line 97 of file glib.c.

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.

Sets up a bitmap that starts at x0,y0 and draws bitmap. The picture is a 24-bit bitmap. It is organized as 8-bit per color per pixel, and the color order is RGB. So picData is supposed to contain at least (width * height * 3) entries. picData has be organized like this: picData = { R, G, B, R, G, B, R, G, B ... }

Parameters
pContextPointer to a GLIB_Context_t in which the bitmap is drawn.
xStart x-coordinate for bitmap
yStart y-coordinate for bitmap
widthWidth of picture
heightHeight of picture
picDataBitmap data 24-bit RGB
Returns
Returns GLIB_OK on success, or else error code

Definition at line 51 of file glib_bitmap.c.

References GLIB_applyClippingRegion().

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
pContextPointer to the GLIB_Context_t
myCharChar to be drawn
xStart x-coordinate for the char (Upper left corner)
yStart y-coordinate for the char (Upper left corner)
opaqueDetermines 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 51 of file glib_string.c.

References __GLIB_Context_t::backgroundColor, __GLIB_Font_t::charSpacing, __GLIB_Font_t::class, __GLIB_Font_t::cntOfMapElements, __GLIB_Context_t::font, __GLIB_Font_t::fontHeight, __GLIB_Font_t::fontRowOffset, __GLIB_Font_t::fontWidth, GLIB_drawPixel(), GLIB_drawPixelColor(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_INVALID_CHAR, GLIB_ERROR_NOTHING_TO_DRAW, GLIB_OK, NumbersOnlyFont, __GLIB_Font_t::pFontPixMap, and __GLIB_Font_t::sizeOfMapElement.

Referenced by GLIB_drawString().

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.

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.

Parameters
pContextPointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color.
xCenterCenter x-coordinate
yCenterCenter y-coordinate
radiusRadius of the circle
Returns
Returns GLIB_OK on success, or else error code

Definition at line 51 of file glib_circle.c.

References GLIB_drawPartialCircle().

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.

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

Parameters
pContextPointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color.
xCenterCenter x-coordinate
yCenterCenter y-coordinate
radiusRadius of the circle
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 142 of file glib_circle.c.

References GLIB_drawLineH(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.

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.

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

Parameters
pContextPointer to the GLIB_Context_t which holds the clipping region
x1Start x-coordinate
y1Start y-coordinate
x2End x-coordinate
y2End y-coordinate
Returns
Returns GLIB_OK on success, or else error code

Definition at line 303 of file glib_line.c.

References GLIB_clipLine(), GLIB_drawLineH(), GLIB_drawLineV(), GLIB_drawPixel(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.

Referenced by GLIB_drawPolygon().

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
pContextPointer to a GLIB_Context_t in which the line is drawn. The line is drawn using the foreground color.
x1Start x-coordinate
y1Start y-coordinate
x2End x-coordinate
Returns
Returns GLIB_OK on success, or else error code

Definition at line 49 of file glib_line.c.

References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, and __GLIB_Rectangle_t::yMax.

Referenced by GLIB_drawCircleFilled(), GLIB_drawLine(), and GLIB_drawRect().

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
pContextPointer to a GLIB_Context_t which the line is drawn. The line is drawn using the foreground color.
x1Start x-coordinate
y1Start y-coordinate
y2End y-coordinate
Returns
Returns GLIB_OK on success, or else error code

Definition at line 113 of file glib_line.c.

References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

Referenced by GLIB_drawLine(), and GLIB_drawRect().

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.

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

Parameters
pContextPointer to a GLIB_Context_t in which the circle is drawn. The circle is drawn using the foreground color.
xCenterCenter x-coordinate
yCenterCenter y-coordinate
radiusRadius of the circle
bitMaskBitmask which decides which octants pixels should be drawn. The LSB is 1. octant, and the MSB is 8. octant.
Returns
Returns GLIB_OK on success, or else error code

Definition at line 84 of file glib_circle.c.

References GLIB_drawPartialCirclePoints(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.

Referenced by GLIB_drawCircle().

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
pContextPointer to a GLIB_Context_t which holds the foreground color and clipping region
xX-coordinate
yY-coordinate
Returns
Returns GLIB_OK on success, or else error code

Definition at line 350 of file glib.c.

References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_rectContainsPoint().

Referenced by GLIB_drawChar(), GLIB_drawLine(), and GLIB_drawPartialCirclePoints().

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
pContextPointer to a GLIB_Context_t which holds the clipping region
xX-coordinate
yY-coordinate
color32-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 381 of file glib.c.

References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_rectContainsPoint().

Referenced by GLIB_drawChar().

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.

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

Parameters
pContextPointer to a GLIB_Context_t which holds the clipping region
xX-coordinate
yY-coordinate
red8-bit red code
green8-bit green code
blue8-bit blue code
Returns
Returns DMD_OK on success, or else error code

Definition at line 421 of file glib.c.

References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_rectContainsPoint().

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

Draws a polygon using Bresnham's Midpoint Line Algorithm.

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.

Parameters
pContextPointer to a GLIB_Context_t which the line is drawn. The lines are drawn using the foreground color.
numPointsNumber of points in the polygon ( Has to be greater than 1 )
polyPointsPointer 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
Returns
Returns GLIB_OK on if at least one element was drawn, or else error code

Definition at line 46 of file glib_polygon.c.

References GLIB_drawLine(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_NOTHING_TO_DRAW, and GLIB_OK.

EMSTATUS GLIB_drawRect ( GLIB_Context_t pContext,
const GLIB_Rectangle_t pRect 
)

Draws a rectangle outline defined by the passed in rectangle.

Parameters
pContextPointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is drawn using the foreground color.
pRectPointer to a rectangle structure
Returns
Returns GLIB_OK on success, or else error code

Definition at line 96 of file glib_rectangle.c.

References __GLIB_Context_t::clippingRegion, GLIB_drawLineH(), GLIB_drawLineV(), GLIB_normalizeRect(), GLIB_OK, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

EMSTATUS GLIB_drawRectFilled ( GLIB_Context_t pContext,
const GLIB_Rectangle_t pRect 
)

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

Parameters
pContextPointer to a GLIB_Context_t in which the rectangle is drawn. The rectangle is filled with the foreground color.
pRectPointer to a rectangle structure
Returns
Returns GLIB_OK on success, or else error code

Definition at line 162 of file glib_rectangle.c.

References __GLIB_Context_t::clippingRegion, __GLIB_Context_t::foregroundColor, GLIB_applyClippingRegion(), GLIB_colorTranslate24bpp(), GLIB_normalizeRect(), __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

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
pContextPointer to a GLIB_Context_t
pStringPointer to the string that is drawn
sLengthnumber of characters in the string
x0Start x-coordinate for the string (Upper left corner)
y0Start y-coordinate for the string (Upper left corner)
opaqueDetermines 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 166 of file glib_string.c.

References __GLIB_Font_t::charSpacing, __GLIB_Font_t::class, __GLIB_Context_t::font, __GLIB_Font_t::fontHeight, __GLIB_Font_t::fontWidth, GLIB_drawChar(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_INVALID_CHAR, GLIB_ERROR_NOTHING_TO_DRAW, GLIB_OK, InvalidFont, and __GLIB_Font_t::lineSpacing.

void GLIB_normalizeRect ( GLIB_Rectangle_t pRect)

Normalize the rectangle that is passed in. 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.

Parameters
pRectPointer to a rectangle structure
Returns
None.

Definition at line 66 of file glib_rectangle.c.

References __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

Referenced by GLIB_drawRect(), and GLIB_drawRectFilled().

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.

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

Parameters
pRectPointer to a rectangle structure
xX-coordinate of point
yY-coordinate of point
Returns
  • Returns false if coordinate is outside the rectangle
  • Returns true otherwise

Definition at line 41 of file glib_rectangle.c.

References __GLIB_Rectangle_t::xMax, and __GLIB_Rectangle_t::yMax.

Referenced by GLIB_drawPixel(), GLIB_drawPixelColor(), and GLIB_drawPixelRGB().

EMSTATUS GLIB_resetClippingRegion ( GLIB_Context_t pContext)

Reset the GLIB_Context_t clipping region to the whole display.

Parameters
pContextPointer to a GLIB_Context_t
Returns
Returns GLIB_OK on success, or else error code

Definition at line 255 of file glib.c.

References __GLIB_Context_t::clippingRegion, GLIB_ERROR_INVALID_ARGUMENT, GLIB_OK, __GLIB_Context_t::pDisplayGeometry, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

EMSTATUS GLIB_resetDisplayClippingArea ( GLIB_Context_t pContext)

Reset the display driver clipping area to the whole display.

Parameters
pContextPointer to a GLIB_Context_t
Returns
Returns GLIB_OK on success, or else error code

Definition at line 236 of file glib.c.

References GLIB_ERROR_INVALID_ARGUMENT, and __GLIB_Context_t::pDisplayGeometry.

Referenced by GLIB_clear().

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

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

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

Parameters
redRed component
greenGreen component
blueBlue component
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 331 of file glib.c.

References BlueShift, GreenShift, and RedShift.

EMSTATUS GLIB_setClippingRegion ( GLIB_Context_t pContext,
const GLIB_Rectangle_t pRect 
)

Sets the clippingRegion of the passed in GLIB_Context_t.

Parameters
pContextPointer to a GLIB_Context_t
pRectPointer 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 131 of file glib.c.

References __GLIB_Context_t::clippingRegion, GLIB_applyClippingRegion(), GLIB_ERROR_INVALID_ARGUMENT, GLIB_ERROR_INVALID_CLIPPINGREGION, GLIB_OUT_OF_BOUNDS, __GLIB_Context_t::pDisplayGeometry, __GLIB_Rectangle_t::xMax, __GLIB_Rectangle_t::xMin, __GLIB_Rectangle_t::yMax, and __GLIB_Rectangle_t::yMin.

Referenced by GLIB_contextInit().

EMSTATUS GLIB_setFont ( GLIB_Context_t pContext,
GLIB_Font_t pFont 
)

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

Parameters
pContextPointer to the GLIB_Context_t
pFontPointer to the new font
Returns
Returns GLIB_OK on success, or else error code

Definition at line 223 of file glib_string.c.

References __GLIB_Context_t::font, GLIB_ERROR_INVALID_ARGUMENT, and GLIB_OK.

Referenced by GLIB_contextInit().