Animated Gif Files
Animated Gif Files
Animated Gif Files
Animated Gif Files
Animated Gif Files
Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files
Animated Gif Files Animated Gif Files
Animated Gif Files
Go Back  Xtreme Visual Basic Talk > > > Animated Gif Files


Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2008, 12:38 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default Animated Gif Files


hello my name is Joaquim... i'm portuguese, soo i'm sorry if my english is confuse... but is just tell me...
i need some information about how can read animated gif files in Visual Basic 6(or using API functions in visual basic 6) and put them in variable...

i have one function but the problem is this function create one file then destroy de file, but i wanted that the function put the subimages in a variable, and of course tell me how many subimages have the is the code:


Code:
Option Explicit

Public RepeatTimes As Long 'This one calculates,
' but don't use in this sample. If You need, You
' can add simple checking at Timer1_Timer Procedure
Public TotalFrames As Long
Public FrameCount As Long

Public Function LoadGif(sFile As String, aImg As Variant) As Boolean
    Dim NomeFicheiro As String
    FrameCount = 0
    NomeFicheiro = Left(sFile, Len(sFile) - 4)
    LoadGif = False
    On Error Resume Next
    Dim fNum As Integer
    Dim imgHeader As String, fileHeader As String
    Dim buf$, picbuf$
    Dim imgCount As Integer
    Dim i&, j&, xOff&, yOff&, TimeWait&
    Dim GifEnd As String
    GifEnd = Chr(0) & Chr(33) & Chr(249)
    fNum = FreeFile
    Open sFile For Binary Access Read As fNum
        buf = String(LOF(fNum), Chr(0))
        Get #fNum, , buf 'Get GIF File into buffer
    Close fNum
    i = 1
    imgCount = 0
    j = InStr(1, buf, GifEnd) + 1
    fileHeader = Left(buf, j)
    LoadGif = True
    i = j + 2
    If Len(fileHeader) >= 127 Then
        RepeatTimes& = Asc(Mid(fileHeader, 126, 1)) + (Asc(Mid(fileHeader, 127, 1)) * 256&)
    Else
        RepeatTimes = 0
    End If

    Do ' Split GIF Files at separate pictures
       ' and load them into Image Array
        imgCount = imgCount + 1
        j = InStr(i, buf, GifEnd) + 3
        If j > Len(GifEnd) Then
            fNum = FreeFile
            Open NomeFicheiro & "1.gif" For Binary As fNum
                picbuf = String(Len(fileHeader) + j - i, Chr(0))
                picbuf = fileHeader & Mid(buf, i - 1, j - i)
                Put #fNum, 1, picbuf
                imgHeader = Left(Mid(buf, i - 1, j - i), 16)
            Close fNum
            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)) * 256&)
                Load aImg(imgCount - 1)
                aImg(imgCount - 1).Left = aImg(0).Left + (xOff * Screen.TwipsPerPixelX)
                aImg(imgCount - 1).Top = aImg(0).Top + (yOff * Screen.TwipsPerPixelY)
            End If
            ' Use .Tag Property to save TimeWait interval for separate Image
            aImg(imgCount - 1).Tag = TimeWait
            aImg(imgCount - 1).Picture = LoadPicture(NomeFicheiro & "1.gif")
            Kill (NomeFicheiro & "1.gif")
            i = j
        End If
        DoEvents
    Loop Until j = 3
' If there are one more Image - Load it
    If i < Len(buf) Then
        fNum = FreeFile
        Open NomeFicheiro & "1.gif" For Binary As fNum
            picbuf = String(Len(fileHeader) + Len(buf) - i, Chr(0))
            picbuf = fileHeader & Mid(buf, i - 1, Len(buf) - i)
            Put #fNum, 1, picbuf
            imgHeader = Left(Mid(buf, i - 1, Len(buf) - i), 16)
        Close fNum
        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)) * 256)
            Load aImg(imgCount - 1)
            aImg(imgCount - 1).Left = aImg(0).Left + (xOff * Screen.TwipsPerPixelX)
            aImg(imgCount - 1).Top = aImg(0).Top + (yOff * Screen.TwipsPerPixelY)
        End If
        aImg(imgCount - 1).Tag = TimeWait
        aImg(imgCount - 1).Picture = LoadPicture(NomeFicheiro & "1.gif")
        Kill (NomeFicheiro & "1.gif")
    End If
    TotalFrames = aImg.Count - 1
End Function
i have this code in a class... can any one help me?
thank you
Reply With Quote
  #2  
Old 04-19-2008, 03:00 PM
Cambalinho_83's Avatar
Cambalinho_83 Cambalinho_83 is offline
Senior Contributor
 
Join Date: Feb 2008
Location: somewhere in space
Posts: 1,296
Default

resolved. thanks to everyone.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Animated Gif Files
Animated Gif Files
Animated Gif Files Animated Gif Files
Animated Gif Files
Animated Gif Files
Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files Animated Gif Files
Animated Gif Files
Animated Gif Files
 
Animated Gif Files
Animated Gif Files
 
-->