Using Bitmap Images

Last modified by Microchip on 2023/11/10 11:03

Using Bitmap Images in a Graphics Application

This page contains information for the Graphics Library found in Microchip Libraries for Applications (MLA). It is not relevant to the MPLAB® Harmony Graphics Library.

Graphic Images

​Bitmap Images

Bitmap images are binary files that contain a pixel-by-pixel description of a graphical image. The value of each pixel is stored in one or more bits of data as defined by the color depth, or Bits Per Pixel (BPP).

​The amount of memory required to store images can be quite large. To conserve the application's program memory, it is possible to store images and fonts in external non-volatile memory.

Back to top

Importing Bitmap Images

Step-by-Step Instructions:
Importing Images to an MLA Graphics Project

The Graphics Resource Converter (GRC) utility is used to import graphics images. (This is the same utility used to import fonts). The GRC can import images from bitmap files (BMP) or JPEG files (JPG or JPEG).

The GRC is located in the MLA Installation directory, …microchip/mla/vYYYY_MM_DD/framework/gfx/utilities/grc.

Linux® and macOS® users launch the resource converter by executing grc.jar, and Microsoft® Windows® users invoke it by executing launch_grc.bat.

Back to top

Using Bitmap Images

Once the image has been imported into the project and rebuilt, you will be able to display the image on the screen. To reference an imported image, you refer to the image by the name given in the header file. When an image file is converted, you will be prompted to enter the name of the file to store the image. This example uses NewImage as the name of the image file.

Refer to the image by the name given in the header file.

Project Tree showing added images

Example of MPLAB® X IDE project tree with the assembly (.s), header (.h), and C (.c) files added.

Back to top

Function Used to Output an Image

GFX_ImageDraw(left, top, &image): Displays the image on the screen at the coordinates designated.

Function to show image at desired location

Microchip Logo example

Back to top

Helpful Functions to Position Images on the Screen

The following functions can be useful to position your images (and objects) on the screen:

GFX_MaxXGet(): Returns the width (in pixels) of the display

GFX_MaxYGet(): Returns the height (in pixels) of the display

GFX_ImageWidthGet(GFX_RESOURCE_HDR pImage): Returns the width of the image in pixels.

GFX_ImageHeightGet(GFX_RESOURCE_HDR pImage): Returns the height of the image in pixels.

Functions to Position Images on the Screen

Example of a centered Microchip Logo

To get a complete list of the functions available for working with bitmap images open GFX_help.png help_mlagfx.jar located in ..microchip/mla/vYYYY_MM_DD/doc…

Back to top