473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Import .gif image in vb6

Hi , i had problem in import .gif image. I had call the image using

Image32.Picture = LoadPicture(App.Path & "\a.gif")

the image appear in my form but it not animated as it was. Please help me to
import gif images in vb6?
Apr 3 '08 #1
3 6131
debasisdas
8,127 Expert 4TB
Please find a related discussion here .
Apr 3 '08 #2
debasisdas
8,127 Expert 4TB
Also check this link for another discussion.
Apr 3 '08 #3
Hi...thanks 4 the reply. I had try using other coding to import .gif image , the problems is the images are flickering to much. The flickering very can be seen strongly when i import many images using image control. The codes are as below

-------the module
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Public RepeatTimes As Long 'This one calculates,
  3. ' but don't use in this sample. If You need, You
  4. ' can add simple checking at Timer1_Timer Procedure
  5. Public TotalFrames As Long
  6.  
  7. Public Function LoadGif(sFile As String, aImg As Variant) As Boolean
  8.     LoadGif = False
  9.     If Dir$(sFile) = "" Or sFile = "" Then
  10.        MsgBox "File " & sFile & " not found", vbCritical
  11.        Exit Function
  12.     End If
  13.     On Error GoTo ErrHandler
  14.     Dim fNum As Integer
  15.     Dim imgHeader As String, fileHeader As String
  16.     Dim buf$, picbuf$
  17.     Dim imgCount As Integer
  18.     Dim i&, j&, xOff&, yOff&, TimeWait&
  19.     Dim GifEnd As String
  20.     GifEnd = Chr(0) & Chr(33) & Chr(249)
  21.     For i = 1 To aImg.Count - 1
  22.         Unload aImg(i)
  23.     Next i
  24.     fNum = FreeFile
  25.     Open sFile For Binary Access Read As fNum
  26.         buf = String(LOF(fNum), Chr(0))
  27.         Get #fNum, , buf 'Get GIF File into buffer
  28.     Close fNum
  29.  
  30.     i = 1
  31.     imgCount = 0
  32.     j = InStr(1, buf, GifEnd) + 1
  33.     fileHeader = Left(buf, j)
  34.     If Left$(fileHeader, 3) <> "GIF" Then
  35.        MsgBox "This file is not a *.gif file", vbCritical
  36.        Exit Function
  37.     End If
  38.     LoadGif = True
  39.     i = j + 2
  40.     If Len(fileHeader) >= 127 Then
  41.         RepeatTimes& = Asc(Mid(fileHeader, 126, 1)) + (Asc(Mid(fileHeader, 127, 1)) * 256&)
  42.     Else
  43.         RepeatTimes = 0
  44.     End If
  45.  
  46.     Do ' Split GIF Files at separate pictures
  47.        ' and load them into Image Array
  48.         imgCount = imgCount + 1
  49.         j = InStr(i, buf, GifEnd) + 3
  50.         If j > Len(GifEnd) Then
  51.             fNum = FreeFile
  52.             Open "temp.gif" For Binary As fNum
  53.                 picbuf = String(Len(fileHeader) + j - i, Chr(0))
  54.                 picbuf = fileHeader & Mid(buf, i - 1, j - i)
  55.                 Put #fNum, 1, picbuf
  56.                 imgHeader = Left(Mid(buf, i - 1, j - i), 16)
  57.             Close fNum
  58.             TimeWait = ((Asc(Mid(imgHeader, 4, 1))) + (Asc(Mid(imgHeader, 5, 1)) * 256&)) * 10&
  59.             If imgCount > 1 Then
  60.                 xOff = Asc(Mid(imgHeader, 9, 1)) + (Asc(Mid(imgHeader, 10, 1)) * 256&)
  61.                 yOff = Asc(Mid(imgHeader, 11, 1)) + (Asc(Mid(imgHeader, 12, 1)) * 256&)
  62.                 Load aImg(imgCount - 1)
  63.                 aImg(imgCount - 1).Left = aImg(0).Left + (xOff * Screen.TwipsPerPixelX)
  64.                 aImg(imgCount - 1).Top = aImg(0).Top + (yOff * Screen.TwipsPerPixelY)
  65.             End If
  66.             ' Use .Tag Property to save TimeWait interval for separate Image
  67.             aImg(imgCount - 1).Tag = TimeWait
  68.             aImg(imgCount - 1).Picture = LoadPicture("temp.gif")
  69.             Kill ("temp.gif")
  70.             i = j
  71.         End If
  72.         DoEvents
  73.     Loop Until j = 3
  74. ' If there are one more Image - Load it
  75.     If i < Len(buf) Then
  76.         fNum = FreeFile
  77.         Open "temp.gif" For Binary As fNum
  78.             picbuf = String(Len(fileHeader) + Len(buf) - i, Chr(0))
  79.             picbuf = fileHeader & Mid(buf, i - 1, Len(buf) - i)
  80.             Put #fNum, 1, picbuf
  81.             imgHeader = Left(Mid(buf, i - 1, Len(buf) - i), 16)
  82.         Close fNum
  83.         TimeWait = ((Asc(Mid(imgHeader, 4, 1))) + (Asc(Mid(imgHeader, 5, 1)) * 256)) * 10
  84.         If imgCount > 1 Then
  85.             xOff = Asc(Mid(imgHeader, 9, 1)) + (Asc(Mid(imgHeader, 10, 1)) * 256)
  86.             yOff = Asc(Mid(imgHeader, 11, 1)) + (Asc(Mid(imgHeader, 12, 1)) * 256)
  87.             Load aImg(imgCount - 1)
  88.             aImg(imgCount - 1).Left = aImg(0).Left + (xOff * Screen.TwipsPerPixelX)
  89.             aImg(imgCount - 1).Top = aImg(0).Top + (yOff * Screen.TwipsPerPixelY)
  90.         End If
  91.         aImg(imgCount - 1).Tag = TimeWait
  92.         aImg(imgCount - 1).Picture = LoadPicture("temp.gif")
  93.         Kill ("temp.gif")
  94.     End If
  95.     TotalFrames = aImg.Count - 1
  96.     Exit Function
  97. ErrHandler:
  98.     MsgBox "Error No. " & Err.Number & " when reading file", vbCritical
  99.     LoadGif = False
  100.     On Error GoTo 0
  101. End Function
---- vb form

Expand|Select|Wrap|Line Numbers
  1. Dim FrameCount As Long
  2.  
  3. Private Sub Command1_Click()
  4.   Timer1.Enabled = False
  5.   If LoadGif(Text1, Image1) Then
  6.      FrameCount = 0
  7.      Timer1.Interval = CLng(Image1(0).Tag)
  8.      Timer1.Enabled = True
  9.   End If
  10. End Sub
  11.  
  12. Private Sub Command2_Click()
  13.    Timer1.Enabled = False
  14. End Sub
  15.  
  16. Private Sub Command3_Click()
  17.    Timer1.Enabled = True
  18. End Sub
  19.  
  20. Private Sub Form_Load()
  21.  
  22.   Text1.Text = App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "e.gif"
  23.   Timer1.Enabled = False
  24. End Sub
  25.  
  26. Private Sub Timer1_Timer()
  27.     If FrameCount < TotalFrames Then
  28.         Image1(FrameCount).Visible = False
  29.         FrameCount = FrameCount + 1
  30.         Image1(FrameCount).Visible = True
  31.         Timer1.Interval = CLng(Image1(FrameCount).Tag)
  32.     Else
  33.         FrameCount = 0
  34.         For i = 1 To Image1.Count - 1
  35.             Image1(i).Visible = False
  36.         Next i
  37.         Image1(FrameCount).Visible = True
  38.         Timer1.Interval = CLng(Image1(FrameCount).Tag)
  39.     End If
  40. End Sub
Please help to solve the problem. Thanks in advance.
Apr 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Raphaël MARC | last post by:
Hello, Can anyone tell me how to open an image and transform it into a list so that the functions of the multi dimensionnal module of numarray (numarray.nd image) can process it ? Do I have...
0
by: leecholim | last post by:
as i knew to import image to a table need to write and execute a package. Please let me know hoe tois.tq
2
by: Aleksandar Cikota | last post by:
Hi all, I have a problem with openning of an image. Here is the Code: from Tkinter import * from PIL import Image, ImageTk from win32com.client import gencache import tkMessageBox
0
by: Andrew | last post by:
Hello Ive been messing around with a simple raw image viewer using Pil and Tkinter However I am running into problems displaying the images they appear to be not correct I believe it is cause of...
3
by: Nebulism | last post by:
Hi everyone, I am working on a module for my GUI that shows one image with an index value below and would use a scrollbar to control which of the images are displayed. The images are stored in a...
1
by: bharathv6 | last post by:
i need to do is modify the image in memory like resizing the image in memory etc ... with out saving it disk as i have to return back the image with out saving it disk PIL supports the use of...
1
by: dbee | last post by:
I'm try to generate a report that will span multiple pages and have dynamic content using python reportlab. I have no issues with regards to generating images and then using ...
1
Thekid
by: Thekid | last post by:
Hi, I have an image similar to a clock, with numbers and letters going around in a circle. I need to extract the numbers and letters from the image and have them print out in a straight line and in...
0
by: BirdaoGwra | last post by:
Hi, I hv created an application with Tkinter/PIL in python25. It can import an image into the canvas. Now could someone kindly tell me how to select and move that image with mouse? Any help would...
2
by: thomas1984 | last post by:
I need to make a GUI which has a fixed window size approx 390 (width) X 6020 (height) It needs to have a fileMenu containing "File" "About" "Exit". In the "file" menu it needs a menuItem called...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.