Animated Gif89a format support

Posted on 1997-12-17
Last Modified: 2012-05-04
I use VB 5.0 Enterprise Edition is there a way that I can read Gif89a files and display the additonal animated frames rather than just the first. If there is a way to do this can you point me to a source or give some sample code so that I can at least find a starting point.
Question by:Mikey121797
  • 5
  • 2
  • 2
  • +1

Expert Comment

ID: 1445680
I don't have VB here right now to test this, but I used this approach with success. After having possibility to check it I'll get back, if there are problems with this.

1.  Add the WebBrowser object to your project (called Microsoft Internet Controls)
2.  Draw a WebBrowser control on your form
3.  In the Form_Load event, call WebBrowser1.Navigate:
        WebBrowser1.Navigate "c:\MyWeb\MyAnimation.gif"

Some things to consider:

 You have to have the gif as a file for the program to load; it can't be compiled into the program as eg. BMPs.

Since the picture is loaded at run time, you have to know the size of the gif when you draw the WebBrowser control.

Even withsome problems, it does give you the ability to display animated gifs (and other graphics formats).

Expert Comment

ID: 1445681
There also is a shareware OCX called anigif.ocx. I don't know it's availability at the moment, but check author's site at

Expert Comment

ID: 1445682
After having possibility to check my answer, I'd like to add following.

Ifyou do what I said with WebBrowser, you notice you got a 3-D look and vertical scroll bar, which you can't get rid of (at least I don't know a way). So as workaround I have done following.

Place a PictureBox on form, set it's looks to flat, no border and solid fill with your forms background color. Place the Webbrowser in this picturebox and make its Left = -30 and Top = -30 (if the scalemode of the picturebox is twips) and then adjust the picturebox's width and height properties so that you dont see WebBrowsers bottom and right borders.

I know this is tedious, but is free, if you have IE3 or better installed.

And that brings me to the final note. You can't distribute WebBrowser control, but you can always install IE on the target machine (clever marketing, MS)

Expert Comment

ID: 1445683
I think the proposed answer (to put a WebBrowser Control on the Form) is much too oversized just to display a crippy GIF98a.

Remember that the WebBrowser Control uses about 4 MB of your main memory, needs to initialize the history and temporary internet files folder, etc. And the loading time of your app will reach new dimensions, that is for each instance of the 'GIF-Viewer' you instanciate (2 GIFs on form -> 5 Minutes wait ?? ;-))

Sorry, I just had to say that

Author Comment

ID: 1445684
Rantanen I tried what you suggested and it just isn't the solution I was looking for. I am looking to display an animated gif with complete control over the transprancy options and etc. D003303 is right the overhead is enormous. I was looking to read the animated Gif directly if possible not depend on an installation of internet explorer. If netcape & internet explorer can display animated gifs there certainly must be a way in VB code to do the same thing and BitBlt it somewhere??! If there is a free OCX somewhere that I don't have to pay for every distributed copy.
Well, I have spewed.
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.


Expert Comment

ID: 1445685
Visual Basic doesn't support animated gifs; however, you can create the same affect.

Create a control array if images.  Assign the picture property of each image in the array to one of the graphics you wish to display in sequence to create the animation.  Make sure you set the top & left properties of all the images to the same value and make sure the pictures are all of the same size.   Use code to loop through the images (using a time delay in each iteration of the loop) making only one visible at time.

To create a continuously looping animation consisting of 5 images in a image control array indexed 0 to 4, put a timer control on your form and start it working in your code as follows:

   Timer1.Timer = 1000 (milliseconds  = 1 second)
   Timer1.Enabled = True

Turn it on or off with:

   Timer1.Enabled = True/False

Code in the Timer Event:

   Private Sub Timer1_Timer()
   Static i As Integer
   Const ImageCount = 5

      Image1(i).Visible = True
      Image1((i + ImageCount - 1) Mod 5).Visible = False
      i = (i + 1) Mod 5

   End Sub


Expert Comment

ID: 1445686
I agree with comments made, except the loading time...not too bad and it is the only free possibility I know . :-)

Mikey, did you check the availability of that OCX, last time I saw info about it was $30 and $40 w/source, not too bad.

mrmick, the only problem with your solution (which is a good way to do animation) is how do you get frames from GIF to the ImageList?

Expert Comment

ID: 1445687
One thing I forgot when talking about *free*. What is Compuserve's position these days? They have rights to that file format and at least earlier they tried to collect some royalties from everybody writing programs to manipulate GIF files.

I might be wrong, but it seems that the selection of free controls is very limited.

Accepted Solution

mrmick earned 200 total points
ID: 1445688
Hey Mikey,

I have not tried this one but you can get a free control to display animated gifs at the following site:

You can't do it using VB alone.  You will have to decode the file yourself or get a control (URL above) that will do it.  The method I provided as an answer yesterday shows how to display the gif once you've got it into an image control array (would also work with a picturebox control array).  There is a welth of info at the following site regarding Gif89a include the spec on how to read it.

Compuserve doesn't want royalties, just recognition unless their policy has changed in the last 2 years.


Author Comment

ID: 1445689
Thank's MrMick the Gif89a specifications are exactly what I needed to get started. AniGif still is not free but it seems to be a newer version than before. Increased Points to 200 enjoy! You deserve it! is a wonderfull sight!

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now