Skip to main content
PFlor.2
Senior II
May 29, 2025
Question

TouchGFX cache use with Bitmap::dynamicBitmapCreateExternal()

  • May 29, 2025
  • 1 reply
  • 453 views

I've been able to successfully use Bitmap::dynamicBitmapCreateExternal() when just loading a bitmap in the frontendappliation and setting up the cache there...

FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
 : FrontendApplicationBase(m, heap)
{
 /*
 * Initialize dynamic bitmap cache;
 * bookkeeping memory for external bitmaps not stored in cache
 */
 uint16_t* const cacheStartAddr = (uint16_t*)myBmpCache;
 const uint32_t cacheSize = sizeof(myBmpCache);
 Bitmap::setCache(cacheStartAddr, cacheSize, 1);

 void* srcPtr = logoGetImagePtr();
 BitmapId bmpId = Bitmap::dynamicBitmapCreateExternal(LCD_X_Size, LCD_Y_Size, srcPtr, 
 Bitmap::RGB888, 0);
 oprSetLogoBmpId(bmpId);
}

I also must be able to load in a different bitmap image is selected by the user and have been able to do this successfully as well by clearing the cache...

 if (logoImportCustomLogo(&fileLoad.filename[value][0]) == Result_success) {
 uint8_t* ptr = logoGetImagePtr();

 /*
 * Initialize dynamic bitmap cache;
 * bookkeeping memory for external bitmaps not stored in cache
 */
 Bitmap::clearCache();
 bmpId = Bitmap::dynamicBitmapCreateExternal(LCD_X_Size, LCD_Y_Size, ptr, 
 Bitmap::RGB888, 0);
 oprSetLogoBmpId(bmpId);
 prmSetVal(Prm_logo, PrmE_logo_customLogo);
 }

However, I will need to be able hand 2 different dynamic images in cache, and when I try to use the cacheRemoveBitmap() the dynamicBitmapCreateExternal() return and invalid bitmapID.  The cacheRemoveBitmap() return true so it seems to execute correctly but the cache doesn't seem to be free for the new bitmap.

 if (logoImportCustomLogo(&fileLoad.filename[value][0]) == Result_success) {
 uint8_t* ptr = logoGetImagePtr();

 /*
 * Initialize dynamic bitmap cache;
 * bookkeeping memory for external bitmaps not stored in cache
 */
 bmpId = oprGetLogoBmpId();
 if (Bitmap::cacheRemoveBitmap(bmpId)) {
 bmpId = Bitmap::dynamicBitmapCreateExternal(LCD_X_Size, LCD_Y_Size, ptr, 
 Bitmap::RGB888, 0);
 oprSetLogoBmpId(bmpId);
 prmSetVal(Prm_logo, PrmE_logo_customLogo);
 }
 }

Any suggestions?   Something simple I'm missing?

 

1 reply

ST Employee
May 30, 2025

Hello @PFlor.2,

It seems you managed to solve your issue there TouchGFX dynamicBitmapCreateExternal() not working... - STMicroelectronics Community, in that case please post the solution you found and select it as a best answer so other can know too.

BR,

PFlor.2
PFlor.2Author
Senior II
May 30, 2025

No the other topic has not been resolved...just bypass it here by using RGB888 but the image is not displayed correctly this way.  This is a separate issue

MM..1
Chief III
May 30, 2025

Start with where and how ....

(uint16_t*)myBmpCache;
 const uint32_t cacheSize = sizeof(myBmpCache);

next how size?

Plus you plan store full LCD size RGB888 ?