Problems with GUI_BMP_DrawEx() and Elm chan FatFs

  • Problems with GUI_BMP_DrawEx() and Elm chan FatFs

    Good afternoon,

    I'm trying to use the GUI_BMP_DrawEx() function in conjunction with FatFs. The modified GetData is the following:

    C Source Code

    1. int APP_GetData(void * p, const U8 * * ppData, unsigned NumBytesReq, U32 Off){FIL phFile; UINT NumBytesRead; U8 _acBuffer[512];f_open(&phFile, (TCHAR const*)p, FA_READ);// Check buffer sizeif (NumBytesReq > sizeof(_acBuffer)) { NumBytesReq = sizeof(_acBuffer); } // Set file pointer to the offset locationf_lseek(&phFile, Off); // Read data into bufferf_read(&phFile, _acBuffer, NumBytesReq, (UINT *)&NumBytesRead); // Set data pointer to the beginning of the buffer*ppData = _acBuffer;// Close filef_close(&phFile);
    2. // Return number of available bytesreturn NumBytesRead;}



    and I call GUI_BMP_DrawEx(APP_GetData, str, 0, 0); where str is something like "Media/img1.BMP"

    No image is loaded but I can correctly plot the image using other functions external to STemWin


    Any suggestion?

    Regards,
    Fabio
  • FIL pFile;

    int APP_GetData(void * p, const U8 * * ppData, unsigned NumBytesReq, U32 Off){
    //You must create an pointer on structure
    FIL *phFile;
    //and then initialize the pointer value is passed to the function APP_GetData
    phFile=(FIL*) p;
    //And then use this pointer to your function
    f_lseek(phFile,Off);
    fresult=f_read(phFile,_acBuffer,NumBytesReq,&NumBytesRead);
    *ppData = _acBuffer;
    return NumBytesRead;
    }

    fresult=f_open (&pFile, Path, FA_READ); // open file
    GUI_BMP_DrawEx(APP_GetData, &pFile,xPos,yPos); // Draw image

    The post was edited 1 time, last by pvo125 ().