Solved

Animated .gif in VB4

Posted on 1998-08-13
12
422 Views
Last Modified: 2013-11-19
I have an animated .gif that is a blinking eye (one image open, one closed). I want to display this in VB4 16 bit (or 32 bit available at a pinch).  How can I display the .gif so that the eye blinks?  So far I have converted the .gif to a .bmp, but the eye is stuck open, i.e. on the first image.  
0
Comment
Question by:AndyJim
  • 4
  • 2
  • 2
  • +4
12 Comments
 

Expert Comment

by:guinness
ID: 1468725
To do animation in Visual Basic:

Cut the GIF into it's frames (you said it has 2 frames, one w/ eye open, one w/ eye closed). Save each frame as it's own file (i.e. Frame one would be eye1.jpg and Frame two would be eye2.jpg). Now, add an Image to your VB form. Call it Image1 for now. Ok, now make the image link to the first frame. Let's say that we saved it in the root c:\ directory. So, the image is going to be linked to "C:\eye1.jpg", right? Now, to loop it infinitely, do this:

Add a Timer component to your form. Name it Timer1 and Disable it (enabled = false). Set it's interval to 1 second. Now, here's what the Sub for the timer is going to look like:

Private Sub Timer1_Timer
Dim Frame As Integer

If (Frame < 1) OR (Frame > 2) Then Frame = 1

If Frame = 1 Then
     Image1.Picture = "C:\eye2.jpg"
     Frame = 2
Elseif Frame = 2 Then
     Image1.Picture = "C:\eye1.jpg"
     Frame = 1
End if

Now, what will this do? Every 1 second it will check to see what the value of the variable Frame is. If the current Frame is #1, then it's going to want to load Frame 2 (C:\eye2.jpg) and it will want to change the value of Frame to 2 since it is now on the 2nd frame. Now, on the 2nd frame, it's going to want to do the opposite and change the picture to Frame 1 (C:\eye1.jpg) and tell the Frame variable that it is now 1 since it's now the 1st frame.

Now, key things to know. First, in your Form Load section you will want to add a line:

Timer1.Enabled = True

This will turn the animation ON. And, also, let's say that someone clicks a button to move to a new form. You will want to add the line:

Timer1.Enabled = False

In the OnClick portion. That way, it will turn the animation OFF.
0
 

Author Comment

by:AndyJim
ID: 1468726
I need to know how to split the eye into its component images.  So far I have opened the .gif in microsoft internet explorer, from which I saved it as a .bmp - how do I split it into separate jpg or bmp files?
0
 

Author Comment

by:AndyJim
ID: 1468727
I need to reopen this because I've got to get the eye blinking at all costs!
0
 

Expert Comment

by:RecilS
ID: 1468728
You'll have to use a program to extract the seperate bitmaps.  I would suggest going to www.download.com and searching for something like +gif and looking through the results to find a promising program.  You can use it once and uninstall it if you like.  Extract the images using it and then do what the first person said.
0
 
LVL 2

Expert Comment

by:cantrell
ID: 1468729
RecilS is correct. The program that I found that is the best and easiest to do this (extract an animated .gif into it's respective frames or images) is Animation Shop from Jasc inc. at www.jasc.com. This will let you select the images in the animated .gif file individually then save them as single bitmaps or whatever. You will then have to do what the other person suggested to get them to display individually when you want them...

Good Luck,
Cantrell
0
 

Expert Comment

by:guinness
ID: 1468730
Heh, go figure. I write code for 30 minutes for Andy, and RecilS comes by, states www.download.com and gets points. Sounds like my job.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:perfect
ID: 1468731
I know it it can be verry important to have such a  -eye blinking- thing in you app.
I'll help you. Send your gif to     perfect_inmate@hotmail.com
and i'll show you.

0
 

Author Comment

by:AndyJim
ID: 1468732
not enough inf.
0
 

Accepted Solution

by:
RecilS earned 50 total points
ID: 1468733
If it took you 30 minutes to write that code then I don't think you should be an expert.  In fact, let me recomend a book called "Learn Visual Basic in 21 Days."
0
 

Author Comment

by:AndyJim
ID: 1468734
Delay, sorry. Busy, busy,busy.  Back soon!
0
 

Expert Comment

by:stingray
ID: 1468735
There is a free anigif control at:

      http://www.pncl.co.uk/~sbutler/ocx/gif89.zip 

only it does not work on all gifs.

Try it.  It could save you a lot of hassles.
0
 

Expert Comment

by:ChasDevlin
ID: 1468736
.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Learn the basics of inputting and editing your text components in Prezi. We will cover how to set styles, position, and group your text components. In your Prezi editor, click anywhere on the canvas to add text: A flashing cursor informs you that yo…
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…

895 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

18 Experts available now in Live!

Get 1:1 Help Now