PNG image not loaded from external memory

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • PNG image not loaded from external memory

    Hi All,

    I am using STM32F429 microcontroller with emWinV5.30 library. We are using the graphics component that is available with MDK. Due to some flash memory limitation, we would like to place all PNG images in an external memory and load the image when required from the external memory. These images are placed on different buttons in the developed screen.

    Following are the steps done to load the PNG from external memory
    1. Downloaded the PNG library from the link and added the same to my application .

    2. Wrote a function to get the data from the PNG file.

    inline int _GetData_PNG(void * p, const uint8_t ** ppData, uint16_t NumBytesReq, uint32_t Offset)
    uint16_t NumBytesRead;
    FILE * phFile;
    uint8_t* pu8Data;

    pu8Data = (uint8_t*)*ppData;
    if (NULL == p)
    printf("\nImage File pointer can't be NULL\n");
    phFile = (FILE *)p;

    /** Moving the pointer to location from where the image is to be read further*/
    fseek(phFile, Offset, SEEK_SET);

    /** Reading the requested number of bytes */
    NumBytesRead = fread(pu8Data, sizeof(uint8_t), NumBytesReq, phFile);

    /** Checking whether the requested bytes equal bytes read, so as to confirm the end of image */
    if (NumBytesRead != NumBytesReq)
    /* Reading possibly reaches the end of the image */
    printf("End of file");
    return NumBytesRead;

    3. Kept the PNG file open before the dialog create.
    4. On dialog initialization tried to load the PNG using GUI_PNG_DrawEx().
    GUI_PNG_DrawEx((GUI_GET_DATA_FUNC *)_GetData_PNG, hFile_CZBlue, 15, 6);

    The get function that is given as the argument is called multilple times to read the file content but no image is displayed.

    In the application, we have allocated 1.6MB memory for GUI and the application contain only 1 screen with 33 buttons.

    How can I resolve this issue?

    Thanks for your support.