Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Animated .gif in VB4

Posted on 1998-08-13
12
Medium Priority
?
451 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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 100 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code 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…
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Suggested Courses
Course of the Month12 days, 14 hours left to enroll

580 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