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?
3 6131
Please find a related discussion here .
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 -
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 Function LoadGif(sFile As String, aImg As Variant) As Boolean
-
LoadGif = False
-
If Dir$(sFile) = "" Or sFile = "" Then
-
MsgBox "File " & sFile & " not found", vbCritical
-
Exit Function
-
End If
-
On Error GoTo ErrHandler
-
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)
-
For i = 1 To aImg.Count - 1
-
Unload aImg(i)
-
Next i
-
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)
-
If Left$(fileHeader, 3) <> "GIF" Then
-
MsgBox "This file is not a *.gif file", vbCritical
-
Exit Function
-
End If
-
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 "temp.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("temp.gif")
-
Kill ("temp.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 "temp.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("temp.gif")
-
Kill ("temp.gif")
-
End If
-
TotalFrames = aImg.Count - 1
-
Exit Function
-
ErrHandler:
-
MsgBox "Error No. " & Err.Number & " when reading file", vbCritical
-
LoadGif = False
-
On Error GoTo 0
-
End Function
---- vb form - Dim FrameCount As Long
-
-
Private Sub Command1_Click()
-
Timer1.Enabled = False
-
If LoadGif(Text1, Image1) Then
-
FrameCount = 0
-
Timer1.Interval = CLng(Image1(0).Tag)
-
Timer1.Enabled = True
-
End If
-
End Sub
-
-
Private Sub Command2_Click()
-
Timer1.Enabled = False
-
End Sub
-
-
Private Sub Command3_Click()
-
Timer1.Enabled = True
-
End Sub
-
-
Private Sub Form_Load()
-
-
Text1.Text = App.Path & IIf(Right(App.Path, 1) = "\", "", "\") & "e.gif"
-
Timer1.Enabled = False
-
End Sub
-
-
Private Sub Timer1_Timer()
-
If FrameCount < TotalFrames Then
-
Image1(FrameCount).Visible = False
-
FrameCount = FrameCount + 1
-
Image1(FrameCount).Visible = True
-
Timer1.Interval = CLng(Image1(FrameCount).Tag)
-
Else
-
FrameCount = 0
-
For i = 1 To Image1.Count - 1
-
Image1(i).Visible = False
-
Next i
-
Image1(FrameCount).Visible = True
-
Timer1.Interval = CLng(Image1(FrameCount).Tag)
-
End If
-
End Sub
Please help to solve the problem. Thanks in advance.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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
|
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
|
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...
|
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...
|
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...
|
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 ...
|
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...
|
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...
|
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...
|
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$) {
}
...
|
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...
|
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...
|
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
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |