cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to Draw bitmap with GUI_BMP_DrawEx() function, ST32F429BI

Aswathy
Associate

I’m working on drawing a .bmp image (480x800) during the bootup screen. Initially, I used the GUI_DrawPixel() function, but it resulted in a significant delay. To improve performance, I tried switching to GUI_BMP_Draw()andGUI_BMP_DrawEx() functions with the following code. However, the function returns 1, and the image is not being drawn.

Has anyone encountered this issue or can provide guidance on why GUI_BMP_DrawEx() might be failing and how to resolve it?

Thank you in advance for your help!

code: 

static void _ShowBMP(const TCHAR* sFilename)
{
int XSize, YSize, XPos, YPos, result;
FIL hFile;
FRESULT res;

res = f_open(&hFile, sFilename, (FA_READ | FA_OPEN_EXISTING));
//GUI_GET_DATA_FUNC *funcPtr = _GetData;
if (res == FR_OK)
{
GUI_ClearRect(0, 0, 480, 800);

//XSize = GUI_BMP_GetXSizeEx(funcPtr, (void *)&hFile);

XSize = GUI_BMP_GetXSizeEx((GUI_GET_DATA_FUNC*)_GetData, (void *)&hFile);
YSize = GUI_BMP_GetYSizeEx((GUI_GET_DATA_FUNC*)_GetData, (void *)&hFile);

XPos = (XSize > 480) ? 0 : (480 - XSize) / 2;
YPos = (YSize > 800) ? 0 : (800 - YSize) / 2;

result = GUI_BMP_DrawEx((GUI_GET_DATA_FUNC*)_GetData, (void *)&hFile, XPos , YPos );
if (!result)
{
GUI_Delay(2000);
}
f_close(&hFile);
}
else
{
printf("Error: Could not open file %s\n", sFilename);
}
}

static unsigned char _acBuffer[0x200];

static int _GetData(void *p, const U8 **ppData, unsigned NumBytesReq, U32 off)
{
FIL *phFile;
phFile = (FIL *)p;
FRESULT res;
unsigned int NumBytesRead;
//unsigned char _acBuffer[512];
if (NumBytesReq > sizeof(_acBuffer)) {
NumBytesReq = sizeof(_acBuffer);
}
res = f_lseek(phFile, off);
res = f_read(phFile, _acBuffer, sizeof(_acBuffer), &NumBytesRead);
*ppData = _acBuffer;
return NumBytesRead;
}

 

2 REPLIES 2
Imen.D
ST Employee

Hello @Aswathy 

Did you call GUI_Init?

The CRC module (in RCC peripheral clock enable register) should also be enabled before using the library.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Yes.. I had already done both. I believe that, as a result of this, the GUI_DrawPixel() function was working fine. 

Are there other such functions/registers to be checked particularly for GUI_BMP_DrawEx()?

Thanks.