Image Pre-Processing

Last modified by Microchip on 2024/04/12 12:45


Image processing is a feature in Microchip Graphics Suite (MGS) Harmony that facilitates the efficient storage of compressed images in Flash memory, which are subsequently decompressed to Random Access Memory (RAM) upon system startup.

Image Processing Diagram

Image pre-processing works best on devices with large amounts of RAM and hardware (HW) acceleration for copying (blit) data between memory locations (i.e., GPU), but have limited Flash memory for storing image assets. Thus, pre-processing can be used primarily for Microchip graphics-accelerated MCUs (like PIC32MZ DA).

Benefits and Tradeoffs

Pre-processing allows for rapid rendering of the decompressed images from RAM to the frame buffer.

By employing preprocessing techniques, users can minimize the storage footprint of image assets in Flash memory while simultaneously taking advantage of the swift rendering capabilities associated with uncompressed images in RAM.

The drawback with image pre-processing is the additional time needed to decompress the images during boot. This can significantly extend the bootup time depending on the size and number of images. 

Configuring Image Assets for Pre-Processing

The steps to configure images for pre-processing can be summarized as follows:

  1. Create a user location using the MGS Harmony Composer Memory Manager.
  2. Enable pre-processing using the MGS Harmony Composer Image Asset Manager.

Details of these steps are described in the next subsections.

Create a User Location Using the Memory Manager in MGS Harmony Composer

Launch the Memory Locations Manager from Composer > Project > Memory Locations.

Back to Top

Click + to add a user-defined memory location.

Memory Manager Settings

Back to Top

Specify the User Location properties as shown. 

  • Set Name to a unique value. This name will be used to assign asset locations.
  • Set Capacity (bytes) to the size of the memory location.
  • Set Access Mode to Write
  • Set Address to start address in RAM to decompress images. Make sure that the start address + capacity are unused regions in RAM.
  • Set Alignment so the images are decompressed to aligned start addresses. This is important if HW acceleration (like GPU) is used to read and write these images to the frame buffer.

Back to Top

Enable Preprocess in Image Assets Manager in MGS Harmony Composer

Launch the Image Assets Manager from Composer > Asset > Images.

Back to Top

Set the image format as stored in Flash. For each image that needs to be pre-processed, the following steps must be performed:

Image pre-processing steps

Back to Top

Set image format properties. 

Enable compression to store the image in reduced size.

Back to Top

Check Preprocess to enable pre-processing.

Set the Write Location to the User Location created for pre-processed images.
Set Color Mode to decompress the image. For the best performance, use the same color mode as the composer project/layer.

Back to Top

In the Memory Locations Manager, the pre-processed images will be shown in the User Location where they are set.

Pre-processed images in user location

At render time, the MGS Harmony Library will automatically use the decompressed image in the User Location (RAM) to draw the image to the frame buffer. If a GPU is available in the device, the library may use the GPU to very quickly copy (blit) the image to the frame buffer.

Back to Top