AnsweredAssumed Answered

How to draw bitmap LPCXpresso54608

Question asked by Oscar Niño on Oct 3, 2018
Latest reply on Oct 22, 2018 by Oscar Niño

Well this is an old question of course, I have read a bitmap from sd, but using a big bitmap(480x272 in my case) my ram gets stock, I know that there is a way drawing an image with GUI_BMP_DrawEx() as user and reference manual says, it do not have to be read into the memory but it use a variable as buffer. The problem is the same. Some examples of emWin use window library and I cannot found it. I have check some questions made before and I have downloaded some examples of them. I´m using MCUXpresso IDE, I would like to share my way to read an image from sd, I was wondering if someone has an example without using window library or telling me how to include it in my project. I would like to draw BMP, JPG, PNG and GIF image I have read reference manual UM03001.pdf but I´m stock in How to read file without  GUI_BMP_Draw() function. I mean; I have modified some examples in old question like this one, these are my functions:

static void _ShowBMP(const TCHAR* sFilename)
{
    int XSize, YSize, XPos, YPos;
    FIL    hFile;
    FRESULT error;
    error = f_open(&hFile, sFilename, (FA_READ | FA_OPEN_EXISTING));
    if (error == FR_OK)
    {
        GUI_ClearRect(0, 0, 480, 272);
        XSize = GUI_BMP_GetXSizeEx(_GetData, &hFile);
        YSize = GUI_BMP_GetYSizeEx(_GetData, &hFile);
        XPos = (XSize > 480) ?  0 : 160 - (XSize / 2);
        YPos = (YSize > 272) ? 60 : 150 - (YSize / 2);
        if (!GUI_BMP_DrawEx(_GetData, &hFile, XPos, YPos))
        {
             GUI_Delay(2000);
        }
        f_close(&hFile);
    }
}

 

and my getdata function

static int _GetData(void * p, const U8 ** ppData, unsigned NumBytesReq, U32 Off)
{
 static char _acBuffer[0x200];
 unsigned int NumBytesRead;
 FIL * phFile;
 phFile = (FIL *)p;
 //
 // Check buffer size
 //
 if (NumBytesReq > sizeof(_acBuffer))
 {
  NumBytesReq = sizeof(_acBuffer);
 }
 //
 // Set file pointer to the offset location
 //
 f_lseek(phFile, 0U);
 //
 // Read data into buffer
 //
 f_read(phFile, _acBuffer, sizeof(_acBuffer), &NumBytesRead);
// NumBytesRead = FS_FRead(_acBuffer, sizeof(char), NumBytesReq, phFile);
 //
 // Set data pointer to the beginning of the buffer
 //
 *ppData = _acBuffer;   <----------------------------------THIS IS THE BUFFER
 //
 // Return number of available bytes
 //
 return NumBytesRead;
}
It is important to say that open function returns a FR_OK parameter that indicates that file has been loaded, but when draw bitmap function is called there is not image showed.
Finally, these files are the way that I use to show bitmap image from sd but it has the problema when I read big images(my RAM ends).
If somebody could help me I will apreciate it so much. I think this is the same way to draw gif, jpg and png images

Attachments

Outcomes