Sunday, June 25th 2017, 5:45am UTC+2

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

HWMSTR

Beginner

Date of registration: Mar 28th 2017

Posts: 4

1

Monday, June 19th 2017, 8:24am

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.

This post has been edited 1 times, last edit by "HWMSTR" (Jun 19th 2017, 9:08am)


SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 309

2

Monday, June 19th 2017, 2:27pm

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
SEGGER - Schoenen has attached the following file:

HWMSTR

Beginner

Date of registration: Mar 28th 2017

Posts: 4

3

Monday, June 19th 2017, 5:12pm

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


SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 309

4

Tuesday, June 20th 2017, 2:52pm

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
SEGGER - Schoenen has attached the following file:
  • GUI_X.zip (4.58 kB - 6 times downloaded - Last download: Yesterday, 8:29pm)

HWMSTR

Beginner

Date of registration: Mar 28th 2017

Posts: 4

5

Wednesday, June 21st 2017, 8:11am

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

SEGGER - Schoenen

Super Moderator

Date of registration: Aug 13th 2015

Posts: 309

6

Wednesday, June 21st 2017, 3:15pm

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:
https://www.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

HWMSTR

Beginner

Date of registration: Mar 28th 2017

Posts: 4

7

Thursday, June 22nd 2017, 6:32am

Hello Sven,
Thank you very much, you've been very helpful.

Have a nice day
Ayman