Solved

Animated .gif in VB4

Posted on 1998-08-13
12
419 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Keep your audience engaged and get the most out of your next presentation with these quick Prezi tips.
In this Micro Tutorial viewers will learn how to remove an unwanted object using Photoshop’s feature known as content-aware fill.
Learn how to set up basic frames and paths in Prezi and understand the open space that Prezi allows you to create presentations in.

706 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

22 Experts available now in Live!

Get 1:1 Help Now