Using Bitmap Images in a Graphics Application

Graphic Images

Bitmap Images

Bitmap images are binary files which 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. Click Here to see a chart of how images size and color density can effect the memory requirements. To conserve the application's program memory it is possible to store images and fonts in external non-volatile memory.

Importing Bitmap images

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

The Graphics Resource Converter utility (GRC) 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 Apple OSX users launch the resource converter by executing grc.jar, and Microsoft Windows users invoke it by executing launch_grc.bat

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.

Bitmap_Def.png
ImageFilesInclude.png

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

Function used to Output an Image

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

BitmapPlain_Code.png
BitmapPlain_Picture.png

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, in pixels, of the image.

GFX_ImageHeightGet(GFX_RESOURCE_HDR * |pImage) returns the height, in pixels, of the image.

ImageCenter_Code.png
ImageCenter_Picture.png
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…

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.