Animated GIF slows down

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

  • Animated GIF slows down

    I have noticed that whenever I am playing animated GIF files it slows with each frame.
    I am using the STM32F429 with the STemWin and FatFS library, and play the file from a micro SD card.
    Below is the applicable code. Am I missing something? I appreciate your assistance with this problem.

    Source Code

    1. int APP_GetData(void * p, const U8 * * ppData, unsigned NumBytesReq, U32 Off){ FIL * phFile; UINT NumBytesRead; phFile = (FIL *) p; // Check buffer size if (NumBytesReq > sizeof(_acBuffer)) { NumBytesReq = sizeof(_acBuffer); } // Set file pointer to the offset location f_lseek(phFile, Off); // Read data into buffer f_read(phFile, _acBuffer, NumBytesReq, (UINT *)&NumBytesRead); // Set data pointer to the beginning of the buffer *ppData = _acBuffer; // Return number of available bytes return NumBytesRead;}
    2. void _ShowGIFEx(const TCHAR* pFile){ GUI_GIF_IMAGE_INFO ImageInfo = {0}; //Info structure of one particular GIF image of the GIF file GUI_GIF_INFO GifInfo = {0}; //Info structure of GIF file int i; int XPos; int YPos;
    3. XPos = 0; YPos = 0;
    4. if (f_open(&fil, pFile, FA_READ) == FR_OK) { GUI_GIF_GetInfoEx(APP_GetData, &fil, &GifInfo); //Get GIF info structure for (i = 0; i < GifInfo.NumImages; i++) { // plot with emWin the file handled by F1 GUI_GIF_DrawSubEx(APP_GetData, &fil, XPos, YPos, i); GUI_GIF_GetImageInfoEx(APP_GetData, &fil, &ImageInfo, i); //Get sub image information Delay_ms(ImageInfo.Delay ? ImageInfo.Delay: 500); //Use the Delay member of the ImageInfo structure for waiting a while } // close the file handled by F1 if (f_close(&fil) == FR_OK) { f_close(&fil); } }}
  • Hi,

    The problem is that if you want to draw an image with a higher index emWin itterates over all images to find the one with correct index.
    For example, with an index of 10 it needs to read 9 times the gif to find the correct one. Of course this takes more time than drawing the first or the second.

    You can avoid this by using memory devices. For this you have to create as many memory devices as images. Afterwards just draw the memory devices to the screen. This take way less time and the delays will be correct.

    I have attached an exsample how this can be done with the windos file system and with SEGGER emFile.


      (1.99 kB, downloaded 233 times, last: )