MT2523 API Reference  LinkIt SDK v4
Graphics

This section provides APIs to display images and basic shapes, such as points, lines, rectangles, circles and polygons. More...

Overview

This section provides APIs to display images and basic shapes, such as points, lines, rectangles, circles and polygons.

Only BMP image is supported in SDK.

Terms and Acronyms

Terms Details
GDI Graphics Device Interface. For more information, please refer to Wikipedia.
RGB An additive color model in which red, green and blue light are added together in various ways to reproduce a broad array of colors. For more information, please refer to Wikipedia.
BLT Bit block transfer, is a data operation commonly used in computer graphics in which several bitmaps are combined into one using a Boolean function. For more information, please refer to Wikipedia.

How to use this module

Functions

void gdi_init (uint32_t width, uint32_t height, gdi_color_format_t color_format, uint8_t *buffer)
 This function initializes the GDI. More...
 
gdi_color_t gdi_get_color_from_argb (uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue)
 This function generates a color from given alpha, red, green, blue. More...
 
void gdi_get_argb_from_color (uint8_t *alpha, uint8_t *red, uint8_t *green, uint8_t *blue, gdi_color_t color)
 This function extracts alpha, red, green, blue from the given color, the value range of the component is relative with the color format. More...
 
void gdi_draw_point (int32_t x, int32_t y, gdi_color_t color)
 This function draws a point on the screen. More...
 
void gdi_draw_line (int32_t x1, int32_t y1, int32_t x2, int32_t y2, gdi_color_t color)
 This function draws a line on the screen. More...
 
void gdi_draw_rectangle (int32_t x1, int32_t y1, int32_t x2, int32_t y2, gdi_color_t color)
 This function draws a rectangle on the screen. More...
 
void gdi_draw_filled_rectangle (int32_t x1, int32_t y1, int32_t x2, int32_t y2, gdi_color_t color)
 This function draws a solid rectangle on the screen. More...
 
void gdi_draw_circle (int32_t x, int32_t y, int32_t radius, gdi_color_t color)
 This function draws a circle on the screen. More...
 
void gdi_draw_filled_circle (int32_t x, int32_t y, int32_t radius, gdi_color_t color)
 This function draws a solid circle on the screen. More...
 
void gdi_draw_filled_polygon (gdi_point_t point[], uint32_t point_num, gdi_color_t color)
 This function draws a solid polygon on current screen. More...
 
void gdi_draw_polygon (gdi_point_t point[], uint32_t point_num, gdi_color_t color)
 This function draws a polygon on current screen. More...
 
gdi_result_t gdi_image_draw_by_id (int32_t x, int32_t y, uint16_t image_id)
 This function draws an image from a resource with original image dimension. More...
 
gdi_result_t gdi_image_draw_resized_by_id (int32_t x, int32_t y, uint32_t width, uint32_t height, uint16_t image_id)
 This function draws an image from a resource with specified dimensions. More...
 
gdi_result_t gdi_image_get_dimension_by_id (uint16_t image_id, uint32_t *width, uint32_t *height)
 This function gets the image dimension by the image resource ID. More...
 
gdi_result_t gdi_lcd_update_screen (uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2)
 This function updates the LCD screen. More...
 

Modules

 Define
 This section defines macros for the GDI.
 
 Struct
 Basic data structure for the GDI.
 

Function Documentation

void gdi_draw_circle ( int32_t  x,
int32_t  y,
int32_t  radius,
gdi_color_t  color 
)

This function draws a circle on the screen.

Parameters
[in]xis the x position of the center of the circle.
[in]yis the y position of the center of the circle.
[in]radiusis the radius of the circle.
[in]coloris the color of the circle.
Returns
void.
void gdi_draw_filled_circle ( int32_t  x,
int32_t  y,
int32_t  radius,
gdi_color_t  color 
)

This function draws a solid circle on the screen.

Parameters
[in]xis the x position of the center of the circle.
[in]yis the y position of the center of the circle.
[in]radiusis the radius of the circle.
[in]coloris the color to fill the circle.
Returns
void.
void gdi_draw_filled_polygon ( gdi_point_t  point[],
uint32_t  point_num,
gdi_color_t  color 
)

This function draws a solid polygon on current screen.

Parameters
[in]pointis the point array.
[in]point_numis the number of elements of the point array.
[in]coloris the color to fill the polygon.
Returns
void.
void gdi_draw_filled_rectangle ( int32_t  x1,
int32_t  y1,
int32_t  x2,
int32_t  y2,
gdi_color_t  color 
)

This function draws a solid rectangle on the screen.

Parameters
[in]x1is the x position of the left-top corner of rectangle.
[in]y1is the y position of the left-top corner of rectangle.
[in]x2is the x position of the right-down corner of rectangle.
[in]y2is the y position of the right-down corner of rectangle.
[in]coloris the color to fill the rectangle.
Returns
void.
void gdi_draw_line ( int32_t  x1,
int32_t  y1,
int32_t  x2,
int32_t  y2,
gdi_color_t  color 
)

This function draws a line on the screen.

Parameters
[in]x1is the x position of the first end point of line.
[in]y1is the y position of the first end point of line.
[in]x2is the x position of the other end point of line.
[in]y2is the y position of the other end point of line.
[in]coloris the color of the line.
Returns
void.
void gdi_draw_point ( int32_t  x,
int32_t  y,
gdi_color_t  color 
)

This function draws a point on the screen.

Parameters
[in]xis the x position of the point.
[in]yis the y position of the point.
[in]coloris the color of the point.
Returns
void.
void gdi_draw_polygon ( gdi_point_t  point[],
uint32_t  point_num,
gdi_color_t  color 
)

This function draws a polygon on current screen.

Parameters
[in]pointis the point array.
[in]point_numis the number of elements of the point array.
[in]coloris the color of polygon.
Returns
void.
void gdi_draw_rectangle ( int32_t  x1,
int32_t  y1,
int32_t  x2,
int32_t  y2,
gdi_color_t  color 
)

This function draws a rectangle on the screen.

Parameters
[in]x1is the x position of the left-top corner of rectangle.
[in]y1is the y position of the left-top corner of rectangle.
[in]x2is the x position of the right-down corner of rectangle.
[in]y2is the y position of the right-down corner of rectangle.
[in]coloris the color of the rectangle frame.
Returns
void.
void gdi_get_argb_from_color ( uint8_t *  alpha,
uint8_t *  red,
uint8_t *  green,
uint8_t *  blue,
gdi_color_t  color 
)

This function extracts alpha, red, green, blue from the given color, the value range of the component is relative with the color format.

Parameters
[out]alphais the alpha component value of the given color.
[out]redis the red component value of the given color.
[out]greenis the green component value of the given color.
[out]blueis the blue component value of the given color.
[in]coloris the given color to extract alpha, red, green, blue.
Returns
void.
gdi_color_t gdi_get_color_from_argb ( uint8_t  alpha,
uint8_t  red,
uint8_t  green,
uint8_t  blue 
)

This function generates a color from given alpha, red, green, blue.

Parameters
[in]alphais the alpha component value to generate the color.
[in]redis the red component value to generate the color.
[in]greenis the green component value to generate the color.
[in]blueis the blue component value to generate the color.
Returns
the generated color.
gdi_result_t gdi_image_draw_by_id ( int32_t  x,
int32_t  y,
uint16_t  image_id 
)

This function draws an image from a resource with original image dimension.

Parameters
[in]xis the x position to draw image.
[in]yis the y position to draw image.
[in]image_idis the image resource ID.
Returns
whether the operation is successful.
gdi_result_t gdi_image_draw_resized_by_id ( int32_t  x,
int32_t  y,
uint32_t  width,
uint32_t  height,
uint16_t  image_id 
)

This function draws an image from a resource with specified dimensions.

Parameters
[in]xis the x position to draw image.
[in]yis the y position to draw image.
[in]widthis the image width to draw.
[in]heightis the image height to draw.
[in]image_idis the image resource ID.
Returns
whether the operation is successful.
gdi_result_t gdi_image_get_dimension_by_id ( uint16_t  image_id,
uint32_t *  width,
uint32_t *  height 
)

This function gets the image dimension by the image resource ID.

Parameters
[in]image_idis the image resource ID.
[out]widthis the image width.
[out]heightis the image height.
Returns
whether the operation is successful.
void gdi_init ( uint32_t  width,
uint32_t  height,
gdi_color_format_t  color_format,
uint8_t *  buffer 
)

This function initializes the GDI.

Parameters
[in]widthis the width of the LCD.
[in]heightis the height of the LCD.
[in]color_formatis the color format of the buffer.
[in]bufferis the buffer containing the drawing content.
Returns
void.
gdi_result_t gdi_lcd_update_screen ( uint32_t  x1,
uint32_t  y1,
uint32_t  x2,
uint32_t  y2 
)

This function updates the LCD screen.

The four parameters are the region to update the LCD screen.

Parameters
[in]x1is x of left-top corner of update region.
[in]y1is y of left-top corner of update region.
[in]x2is x of right-down corner of update region.
[in]y2is y of right-down corner of update region.
Returns
whether the operation is successful.