Drawing Gif in a Window or a dialog

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

  • Drawing Gif in a Window or a dialog

    Hello,
    Can you please provide me with a simple example using GIF inside a window or a dialog (preferably using image widget)? I can get the GIF to work properly if there is no window; however, once I add a window with an image in the background, I can't get the gif to display.
    Best Regards.

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

  • Hi,

    Attached is an example which uses an IMAGE widget to draw an animated GIF. The IMAGE widget is part of a dialog. The dialog draws a bitmap into the background.

    The GIF is converted into a c-array and added into the code.

    Regards,
    Sven
    Files
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello Sven,
    Thank you for the example. I got the example you provided me to run ;however, I did not see the gif image go through sequence of frames. Basically the image was still, and I was expecting to see some animation.
    I appreciate your time.
    Ayman

  • Hi,

    On my end it is animated. Do you provide emWin a proper time base?

    Take a look into GUI_X.c (or GUI_X_embOS.c, GUI_X_FreeRTOS.c, etc.) There are some functions which are getting called by emWin if any timerelated gets called.

    I have attached the files. You can 'feed' those routines by a timebase provided by an RTOS or you set up a hardware timer on you own.

    Regards,
    Sven
    Files
    • GUI_X.zip

      (4.58 kB, downloaded 545 times, last: )
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello Sven,
    Thank you very much for your suggestion. Indeed I was not providing any timebase to GUI_X_GetTime(void) in GUI_X.c, and now the gif works as expected!


    Another question in regards to the gif function, I converted a gif file to C code using the bitmap converter, and modified the example you provided me. I replaced IMAGE_SetGIF(hItem, pData, FileSize) with IMAGE_SetBitmap(hItem, &bmsimple_gif), and I saw a still image with no animation. does IMAGE_SetBitmap() function support gif?


    Thanks,
    Ayman
  • Hi,

    In my sample I converted the GIF into an c-array which contains the same information as the original GIF. To convert the GIF into a c-file you can use the tool linked below. If a GIF gets opened by the Bitmap Converter it shows and converts only the first image.

    Bin2C converting tool:
    segger.com/downloads/emwin/Bin2C

    Also the function IMAGE_SetBitmap() supports only static images.

    But with the Bitmap Converter it is also possible to create a c-file with animation. To do this follow this steps:

    1. Open Bitmap Converter
    2. Click File -> Create animated sprite from GIF
    3. Choose the GIF file you want to convert
    4. Give it a name and save it

    Now this animation can be displayed by using the Sprite API.

    It is also possible to draw a single image of this sprite with e.g GUI_DrawBitmap(). This way it is possible to create an animation without the Sprite API.

    Please keep in mind that this file can get pretty big, depending on the number of different images and its size in x and y.

    Regards,
    Sven
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.