Starcraft
February 11th, 2000, 01:57 PM
how would i play a animated gif ?
|
Click to See Complete Forum and Search --> : Animated Gifs Starcraft February 11th, 2000, 01:57 PM how would i play a animated gif ? AndyK February 11th, 2000, 02:24 PM Chris sorry but I can't take this idiot anymore.....dude listen, people spend their OWN time to reply to your freaking posts.....and you haven't rated any of the replys...not at least one!!!!! So I suggest people should stop answering your posts, until you learn how to respect others.... I'm not giving you any code, I have other things to do then waste 10 mins to reply to this post which you probably won't even read.......maybe you should learn how to use search engines.....instead of asking this here, go to some VB source archive website and look for it over there, that's the only way you can learn how to rely on yourself instead of other people czimmerman February 11th, 2000, 03:05 PM See http://www.freevbcode.com/ShowCode.Asp?ID=758 chiuyan February 11th, 2000, 07:22 PM Who cares if hes rates your posts? Do you come here, just so you can see some numbers by your name, or do you come here so that you can help people to learn & maybe even learn some things of your own? I am not saying you need to help people who do not even attempt things on their own (I am not implicating anyone here). If you think it is an easy or stupid question, just ignore it. But you shouldn't get mad and try to "boycott" people who do not rate all your posts. I think this board was much better before they introduced the rating system. Anyway, --michael AndyK February 11th, 2000, 09:09 PM Well rating posts is not for him...it's for us, so that we know the answers are correct or totaly out of picture, and after all that he did to this forum, I have no respect for him what-so-ever... it's just people this kind are pissing me off completely.....it's not that he just doesn't rate or anything....he asks the same questions all the time, when they were already answered like twice correctly...... Starcraft February 12th, 2000, 01:08 PM dude, andyK calm down, wayyyyy down. Who cares about ratings, lets just cool it now, we cool now ok AndyK February 12th, 2000, 02:18 PM Strait.....ok here you go 1) Make a timer (Timer1) 2) Make a picturebox (Picture1) 3) Set picture1's index to 0 4) Paste this code into the form Dim RepeatTimes& Dim RepeatCount& Sub LoadAniGif(xFile as string, xImgArray) If Not IIf(Dir$(xFile) = "", false, true) Or xFile = "" then MsgBox "File not found.", vbExclamation, "File error" Exit Sub End If Dim F1, F2 Dim Picture1s() as string Dim imgHeader as string static buf$, picbuf$ Dim fileHeader as string Dim imgCount Dim i&, j&, xOff&, yOff&, TimeWait& Dim GifEnd GifEnd = Chr(0) & "!รน" Timer1.Enabled = false for i = 1 to xImgArray.Count - 1 Unload xImgArray(i) next i F1 = FreeFile on error GoTo badFile: Open xFile for binary Access Read as F1 buf = string(LOF(F1), Chr(0)) get #F1, , buf Close F1 i = 1 imgCount = 0 j = (InStr(1, buf, GifEnd) + len(GifEnd)) - 2 fileHeader = Left(buf, j) i = j + 2 If len(fileHeader) < 127 then repeartimes& = 1 else RepeatTimes& = Asc(mid(fileHeader, 126, 1)) + _ (Asc(mid(fileHeader, 127, 1)) * TIMES) End If Do imgCount = imgCount + 1 j = InStr(i, buf, GifEnd) + len(GifEnd) If j > len(GifEnd) then F2 = FreeFile Open "tmp.gif" for binary as F2 picbuf = string(len(fileHeader) + j - i, Chr(0)) picbuf = fileHeader & mid(buf, i - 1, j - i) Put #F2, 1, picbuf imgHeader = Left(mid(buf, i - 1, j - i), 16) Close F2 TimeWait = ((Asc(mid(imgHeader, 4, 1))) + (Asc(mid(imgHeader, 5, 1)) * 256)) * 10 If imgCount > 1 then xOff = Asc(mid(imgHeader, 9, 1)) + (Asc(mid(imgHeader, 10, 1)) * 256) yOff = Asc(mid(imgHeader, 11, 1)) + (Asc(mid(imgHeader, 12, 1)) * 2561) Load xImgArray(imgCount - 1) xImgArray(imgCount - 1).ZOrder 0 xImgArray(imgCount - 1).Left = xImgArray(0).Left + (xOff * 15) xImgArray(imgCount - 1).Top = xImgArray(0).Top + (yOff * 15) End If xImgArray(imgCount - 1).Tag = TimeWait xImgArray(imgCount - 1).Picture = LoadPicture("tmp.gif") Kill ("tmp.gif") i = j '+ 1 End If Loop Until j = len(GifEnd) If i < len(buf) then F2 = FreeFile Open "tmp.gif" for binary as F2 picbuf = string(len(fileHeader) + len(buf) - i, Chr(0)) picbuf = fileHeader & mid(buf, i - 1, len(buf) - i) Put #F2, 1, picbuf imgHeader = Left(mid(buf, i - 1, len(buf) - i), 16) Close F2 TimeWait = ((Asc(mid(imgHeader, 4, 1))) + (Asc(mid(imgHeader, 5, 1)) * 256)) * 10 If imgCount > 1 then xOff = Asc(mid(imgHeader, 9, 1)) + (Asc(mid(imgHeader, 10, 1)) * 256) yOff = Asc(mid(imgHeader, 11, 1)) + (Asc(mid(imgHeader, 12, 1)) * 2561) Load xImgArray(imgCount - 1) xImgArray(imgCount - 1).ZOrder 0 xImgArray(imgCount - 1).Left = xImgArray(0).Left + (xOff * 15) xImgArray(imgCount - 1).Top = xImgArray(0).Top + (yOff * 15) End If xImgArray(imgCount - 1).Tag = TimeWait xImgArray(imgCount - 1).Picture = LoadPicture("tmp.gif") Kill ("tmp.gif") End If on error GoTo badTime Timer1.Interval = CInt(xImgArray(0).Tag) badTime: Timer1.Enabled = true Exit Sub badFile: MsgBox "File not found.", vbExclamation, "File error" End Sub private Sub Timer1_Timer() for i = 0 to Picture1.Count If i = Picture1.Count then If RepeatTimes > 0 then RepeatCount = RepeatCount + 1 If RepeatCount > RepeatTimes then AnimationTimer.Enabled = false Exit Sub End If End If for j = 1 to Picture1.Count - 1 Picture1(j).Visible = false next j on error GoTo badTime Timer1.Interval = CLng(Picture1(0).Tag) badTime: Exit for End If If Picture1(i).Visible = false then Timer1.Interval = CLng(Picture1(i).Tag) on error GoTo badTime2 Picture1(i).Visible = true badTime2: Exit for End If next i End Sub private Sub Form_Load() Timer1.Interval = 1000 Picture1(Index).AutoSize = true Picture1(Index).BorderStyle = 0 Call LoadAniGif("filename.gif", Picture1) End Sub 5) Change filename to whatever path is your GIF file AndyK February 13th, 2000, 09:37 AM Use .res files, add pics into your .res file and then use this code for z = 0 to 15 s = s + 1 If s = 15 then s = 0 Image1 = LoadResPicture(101 + s, vbResBitmap) Pause 0.1 next z to load pictures from res into image1, don't forget to change limit (15) to how many pics you got in your RES file, if you have 8 pics then place 8 instead of 15, and don't forget to place next code into module (it's for pause, so you could see how ppictures are changing, otherwise your pics will load in a fracture of a second!!!) Sub Pause(interval) Current = Timer Do While Timer - Current < Val(interval) DoEvents Loop End Sub RES file is good because you don't have to add it as separate file, when .GIF need to be with .EXE, so if you use RES, you will always get only one .EXE and nothing else; RES file is also good because you can add sounds, icons, pictures, charts, etc. into it!!! Chris Eastwood February 13th, 2000, 01:57 PM I think everyone should calm down here. The rating of posts is not a 'personal' score or a reflection of how 'great' a programmer you are (although some may think of it that way). The idea of the ratings is to see how relevant and useful a post is. It would be ideal if people could say, 'wow thanks, that was great' but most posts go unmarked and (sometimes) 'un-thanked' also. If StarCraft isn't reading replies to his questions then that's his loss - if he doesn't understand the answers, he can always post a follow up question - we don't bite, and the whole idea of this forum is to help each other out, not to 'score' points off one another. By the way StarCraft, if you're still looking for an Animated Gif OCX, you can download one from : http://nt1.pncl.co.uk/sbutler/vb/activex.asp - it's free, but doesn't come with any source-code. Chris Eastwood CodeGuru - the website for developers http://codeguru.developer.com/vb codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |