2024-10-02 10:32 PM - edited 2024-10-02 11:11 PM
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;
}
2024-10-03 03:28 AM
Hello @Aswathy
Did you call GUI_Init?
The CRC module (in RCC peripheral clock enable register) should also be enabled before using the library.
2024-10-03 05:00 AM - edited 2024-10-03 05:16 AM
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.