This section explains how to use Dynamic Bitmaps. Recall that standard bitmaps are compiled into the application and therefore must be available at compile time. The bitmaps are converted from e.g. PNG files and stored in an internal format together with size and format information.
It is also possible to create a bitmap in RAM at runtime. This is called a dynamic bitmap. A dynamic bitmap can be used just as the static bitmaps that are compiled into the application. This means that you can use a dynamic bitmap with e.g. the Image and Button widgets.
When you create a dynamic bitmap the RAM for the pixels is allocated from the bitmap cache. You must therefore configure a bitmap cache before you can create dynamic bitmaps.
See the article on bitmap caching for configuration instructions.
It is required to define the maximum number of Dynamic Bitmaps used in your application. This maximum is passed to TouchGFX together with the bitmap cache address and size. Here we configure a bitmap cache with up to 4 dynamic bitmaps:
To use the dynamic bitmap we need a widget to show it. So insert an Image widget in the view (in code or in the Designer):
Create the dynamic bitmap in setupScreen. Here we use the 16bpp format RGB565. If your framebuffer is e.g 24 bit use RGB888. To create a transparent bitmap, use the format ARGB8888:
If you want to load your image from a file you can replace the call to memset with your loader code. See the article Loading Images At Runtime
The dynamic bitmap operations are all placed in the Bitmap class.
The following method creates a dynamic bitmap with the width, height and bitmap format specified. The bitmap is only created if enough unused memory is available. The method returns BITMAP_INVALID if the bitmap was not created.
This method deletes a dynamic bitmap.
The following method returns the address of the dynamic bitmap. This method is used by file loaders to copy image data into the bitmap.
The following method sets the solid rectangle of a dynamic bitmap.
Read more about the "solid area" concept in the Custom Widgets article.
By default the solid area is set to be the whole bitmap for non-transparent formats like RGB565 and RGB888. It is set to empty for transparent formats like ARGB8888.