I thought it would be nice to display some animated GIFs on some of my
forms. I put a PictureBox control on a form, and loaded my GIF file in. It
animates, but not properly. It seems very jerky and dwells on some frames
longer than it should. Searching for this problem, I have found several
people who have stated that animated GIFs don't work in a PictureBox at all,
and you have to use the ImageAnimator. I assume they must be referring to an
older version, because I do get some animation, it's just not quite right. I
am using VB2005 Express.
I thought it might be a problem with running under the IDE, but I still get
the same problem if I build the project and run the release exe.
I looked up ImageAnimator in the help, and it is not especially helpful, but
there was some sample code. I tried this, and I get exactly the same
problem. The image displays and animates, but the timing seems all wrong. If
I use the image preview in Windows XP the image displays fine, so I don't
think it's a problem with the GIF file itself.
Any suggestions, greatly appreciated.
TIA
Phil. 27 13535
Phil,
You are sure that you set the properties of the picturebox right
By instance this ones let it look on every screen different http://msdn2.microsoft.com/en-us/lib....sizemode.aspx
Cor
"Phil" <N/Aschreef in bericht news:13*************@corp.supernews.com...
>I thought it would be nice to display some animated GIFs on some of my forms. I put a PictureBox control on a form, and loaded my GIF file in. It animates, but not properly. It seems very jerky and dwells on some frames longer than it should. Searching for this problem, I have found several people who have stated that animated GIFs don't work in a PictureBox at all, and you have to use the ImageAnimator. I assume they must be referring to an older version, because I do get some animation, it's just not quite right. I am using VB2005 Express.
I thought it might be a problem with running under the IDE, but I still
get the same problem if I build the project and run the release exe.
I looked up ImageAnimator in the help, and it is not especially helpful,
but there was some sample code. I tried this, and I get exactly the same
problem. The image displays and animates, but the timing seems all wrong.
If I use the image preview in Windows XP the image displays fine, so I
don't think it's a problem with the GIF file itself.
Any suggestions, greatly appreciated.
TIA
Phil.
Hi Phil,
Based on my understanding, you'd like to display some animated GIFs on some
of your forms. But you find that the animated GIF is slower when it is
displayed in a WinForm than in the image preview in the Windows Explorer.
If I'm off base, please feel free to let me know.
I performed some tests and did reproduce the problem. When I display an
animated GIF in a PictureBox on a WinForm, the animation is a little slower
than displayed in the Internet Explorer.
I guess WinForm limits the maximum frames displayed per second. I have
seached in our inner database, but unfortunately, I haven't found any
information about it so far.
I will consult this issue in our inner discussion group and as soon as I
get any news, I will get it back to you.
In addtion, although my animated GIF is displayed slower in a WinForm, but
the animation is smooth. As you have mentioned, the animated GIF you're
using seems jerky when it is display in a form. Could you please send me
the animated GIF? To get my actual email address, remove 'online' from my
displayed email address.
Thank you for your cooperation and patience!
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
You are sure that you set the properties of the picturebox right
By instance this ones let it look on every screen different
http://msdn2.microsoft.com/en-us/lib....sizemode.aspx
I set SizeMode to AutoSize, but I'll try setting the size manually and see
if that makes any difference.
That wouldn't explain the problem when using ImageAnimator though, as in
that example it was drawing directly on the form.
>You are sure that you set the properties of the picturebox right
>> By instance this ones let it look on every screen different
http://msdn2.microsoft.com/en-us/lib....sizemode.aspx
I set SizeMode to AutoSize, but I'll try setting the size manually and see
if that makes any difference.
I tried setting SizeMode to Normal, and it makes no difference.
Within the IDE or when running the program?
It makes no difference whether I run the program from within the IDE or
compile it, and run the exe.
In the IDE, I don't see any
animation at all.
I don't see any animation when using the form designer. That is not a
problem. I am only concerned with the runtime behaviour.
When running the program, it is displayed correctly.
Not for me :(
>(VB 2005 Express)
That is what I am using too.
"Phil" <N/Aschrieb
>
Within the IDE or when running the program?
It makes no difference whether I run the program from within the IDE
or compile it, and run the exe.
In the IDE, I don't see any
animation at all.
I don't see any animation when using the form designer. That is not
a problem. I am only concerned with the runtime behaviour.
When running the program, it is displayed correctly.
Not for me :(
(VB 2005 Express)
That is what I am using too.
What else does the application do? Does it do any other job while you are
watching the image? Maybe you are using System.Windows.Forms.Timer that does
things from time to time?
Have you already tried it in a new project?
Armin
What else does the application do?
Nothing yet. First thing I tried when it didn't work was to create a new
project to ensure nothing else might be interfering.
I tried calling UpdateFrames twice in my Paint event handler, and now it
is displaying the new frame correctly.
Actually that seemed to work once, but is now not working again. :-(
"Phil" <N/Awrote in message news:13*************@corp.supernews.com...
>I tried calling UpdateFrames twice in my Paint event handler, and now it is displaying the new frame correctly.
Actually that seemed to work once, but is now not working again. :-(
What does seem to fix it though is calling
Threading.Thread.Sleep(10)
before calling UpdateFrames.
"Phil" <N/Awrote in message news:13*************@corp.supernews.com...
>I thought it would be nice to display some animated GIFs on some of my forms. I put a PictureBox control on a form, and loaded my GIF file in. It animates, but not properly. It seems very jerky and dwells on some frames longer than it should. Searching for this problem, I have found several people who have stated that animated GIFs don't work in a PictureBox at all, and you have to use the ImageAnimator. I assume they must be referring to an older version, because I do get some animation, it's just not quite right. I am using VB2005 Express.
I thought it might be a problem with running under the IDE, but I still
get the same problem if I build the project and run the release exe.
I looked up ImageAnimator in the help, and it is not especially helpful,
but there was some sample code. I tried this, and I get exactly the same
problem. The image displays and animates, but the timing seems all wrong.
If I use the image preview in Windows XP the image displays fine, so I
don't think it's a problem with the GIF file itself.
Any suggestions, greatly appreciated.
TIA
Phil.
It seems this may be a known problem.
I found this article http://visualbasic.about.com/od/usingvbnet/a/GDIP10.htm
which says:
"... the ImageAnimator class in .NET doesn't handle timing the display of
the individual images very well. GDI+ uses the event processing provided by
Windows Forms and the Windows message pump. That's just not good enough to
keep the animation from being jumpy and even skip frames entirely. "
On Aug 13, 9:41 am, "Phil" <N/Awrote:
I thought it would be nice to display some animated GIFs on some of my
forms. I put a PictureBox control on a form, and loaded my GIF file in. It
animates, but not properly. It seems very jerky and dwells on some frames
longer than it should. Searching for this problem, I have found several
people who have stated that animated GIFs don't work in a PictureBox at all,
and you have to use the ImageAnimator. I assume they must be referring to an
older version, because I do get some animation, it's just not quite right. I
am using VB2005 Express.
I thought it might be a problem with running under the IDE, but I still get
the same problem if I build the project and run the release exe.
I looked up ImageAnimator in the help, and it is not especially helpful, but
there was some sample code. I tried this, and I get exactly the same
problem. The image displays and animates, but the timing seems all wrong. If
I use the image preview in Windows XP the image displays fine, so I don't
think it's a problem with the GIF file itself.
Any suggestions, greatly appreciated.
TIA
Phil.
Hi,
Can you use AxAnimation in Express? It would be in the Tools/Choose
ToolBox items, and select the Com tab.
Thats what I am currently using. Also, there is a project in Code
Project named .NET Animation Control that you can add, I have tried
that also and it works. I do use .avi files though.
Jeff
Hi,
Can you use AxAnimation in Express? It would be in the Tools/Choose
ToolBox items, and select the Com tab.
I have AXBrowse.AXBrowser but not AXAnimation.
Presumably this is something that is part of some other application and
needs to be installed separately.
Thats what I am currently using. Also, there is a project in Code
Project named .NET Animation Control that you can add, I have tried
that also and it works. I do use .avi files though.
I would like to be able to use AVI files too, so I may check that out.
Thanks,
Phil.
What does seem to fix it though is calling
Threading.Thread.Sleep(10)
before calling UpdateFrames.
It might seem odd that adding a delay should prevent the animation from
skipping frames, but this could be explained if there is a rounding error in
the handling of time in ImageAnimator.
I would guess that the way it works is that the Animate method stores the
current time, and then sets up a timer to trigger the FrameChange event.
Each time the FrameChanged event is fired, it would update the stored time,
and set a new timer for the next frame.
If the precision of the variable used to store this time and the precision
of the variable used to store the timer interval are different, it is
possible either for the event to be raised slightly too early or for
UpdateFrames to think it is not yet time for the next frame.
If someone from Microsoft is reading, perhaps they could get someone to look
at the code for ImageAnimator, to see if this might be what's happening. If
so, it should be a simple fix, to make it round up instead of down where the
rounding is occuring.
What puzzles me though is that putting a delay in the Paint event handler
before calling UpdateFrames fixes the problem, but putting the delay in the
FrameChanged event handler before calling Invalidate does not work.
>Also, there is a project in Code Project named .NET Animation Control that you can add, I have tried that also and it works. I do use .avi files though.
I would like to be able to use AVI files too, so I may check that out.
I found this. It is called CGAnimation, and is written in C#. I loaded into
C# and I got a message that it was written for an older version of visual
studio. It seemed to convert it OK, and I was able to build the DLL.
I added this to my toolbox in VB, and was able to get it working, although
I've found a couple of problems with it. Firstly it doesn't display properly
in the designer. This isn't a major problem, but is annoying. Secondly the
Transparent property does not seem to work correctly. It will correctly use
the form's background colour, but if the form has a background image, it
does not display it correctly.
Also, it seems OK with an AVI, but does not seem to work with an animated
GIF. This may be by design, I'm not sure.
Does anyone have any experience using this control? Is it worth trying to
convert this to VB and trying to debug it, or is there a better way of
displaying AVI files?
Thanks,
Phil.
Try this:
control panel -display: Folder "settings", button "advanced", folder
"problem...", reduce hardware acceleration to minimum. Accept.
(maybe text's slightly differ; I don't have the English OS version)
Does it make a difference?
Armin
"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Try this:
control panel -display: Folder "settings", button "advanced", folder
"problem...", reduce hardware acceleration to minimum. Accept.
(maybe text's slightly differ; I don't have the English OS version)
Control PanelDisplaySettingsAdvancedTroubleshooting
>
Does it make a difference?
No. I set the acceleration to None, but it makes no difference.
"Phil" <N/Aschrieb
>
"Armin Zingler" <az*******@freenet.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Try this:
control panel -display: Folder "settings", button "advanced",
folder "problem...", reduce hardware acceleration to minimum.
Accept.
(maybe text's slightly differ; I don't have the English OS
version)
Control PanelDisplaySettingsAdvancedTroubleshooting
Does it make a difference?
No. I set the acceleration to None, but it makes no difference.
Hmmm.. Another attempt: Add a Timer (system.windows.forms.timer), set
interval to 10. In it's tick event, call ThePicturebox.Refresh. Any
difference?
Try booting in safe mode. Difference?
Armin
On Aug 15, 3:13 am, "Phil" <N/Awrote:
Hi,
Can you use AxAnimation in Express? It would be in the Tools/Choose
ToolBox items, and select the Com tab.
I have AXBrowse.AXBrowser but not AXAnimation.
Presumably this is something that is part of some other application and
needs to be installed separately.
Thats what I am currently using. Also, there is a project in Code
Project named .NET Animation Control that you can add, I have tried
that also and it works. I do use .avi files though.
I would like to be able to use AVI files too, so I may check that out.
Thanks,
Phil.
Hi,
In the ToolBox items, click the com tab and look for an item that you
can named,
Microsoft Animation Control 6.0(SP4). Placing that on your form will
allow you to run
animations. If you do not see that, click the browse and go to Windows/
System32
and look for a dll named mscomctl2, something like that, and adding it
should give the amination
control.
Jeff
Hi Phil,
Sorry for my delayed reply!
You have mentioned that you found a workaround to use WebBrowser to display
the animated GIFs on a form. But the problems of this workaround are that
it's difficult to change the back ground color of the WebBrowser control
and load the animated GIFs from the application resources.
I have done some research on these two problems, but unfortunately I didn't
find a solution for them.
In fact, animated GIF has stored timing interval information of each frame
in the GIF file itself. We can retrieve it through the PropertyItems
property of the Image class. Once we get this information, we could use a
System.Windows.Forms.Timer component to control and display the animated
GIF. The following is a sample, which requires you add a PictureBox on the
form.
Imports System.Drawing.Imaging
Imports System.IO
Public Class Form1
Dim gif As Image = Image.FromFile(Application.StartupPath &
"\test1.gif")
Dim fcount As Integer = gif.GetFrameCount(FrameDimension.Time)
Dim interval(fcount) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim item As PropertyItem = gif.GetPropertyItem(20736)
Dim index As Integer = 0
For i As Integer = 0 To gif.GetFrameCount(FrameDimension.Time) - 1
interval(i) = BitConverter.ToInt32(item.Value, index)
index += 4
Next
ShowGif()
' the timing interval storted in the GIF file is of the unit of
centi-second
Me.Timer1.Interval = interval(findex) * 10
Me.Timer1.Start()
End Sub
Dim findex As Integer = 0
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
findex += 1
If (findex = fcount) Then
findex = 0
End If
ShowGif()
Me.Timer1.Interval = interval(findex) * 10
End Sub
Private Sub ShowGif()
gif.SelectActiveFrame(FrameDimension.Time, findex)
Me.PictureBox1.Invalidate()
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
e.Graphics.DrawImage(gif, New Point(0, 0))
End Sub
End Class
I display the GIF you provided using the above code and the animation on
the PictureBox is not slower than it is in IE.
Please try my sample code out on your side and let me know the result.
Sincerely,
Linda Liu
Microsoft Online Community Support
Thanks Linda, I'll give this a try and let you know if it helps.
Cheers,
Phil.
"Linda Liu [MSFT]" <v-****@online.microsoft.comwrote in message
news:av**************@TK2MSFTNGHUB02.phx.gbl...
Hi Phil,
Sorry for my delayed reply!
You have mentioned that you found a workaround to use WebBrowser to
display
the animated GIFs on a form. But the problems of this workaround are that
it's difficult to change the back ground color of the WebBrowser control
and load the animated GIFs from the application resources.
I have done some research on these two problems, but unfortunately I
didn't
find a solution for them.
In fact, animated GIF has stored timing interval information of each frame
in the GIF file itself. We can retrieve it through the PropertyItems
property of the Image class. Once we get this information, we could use a
System.Windows.Forms.Timer component to control and display the animated
GIF. The following is a sample, which requires you add a PictureBox on the
form.
Imports System.Drawing.Imaging
Imports System.IO
Public Class Form1
Dim gif As Image = Image.FromFile(Application.StartupPath &
"\test1.gif")
Dim fcount As Integer = gif.GetFrameCount(FrameDimension.Time)
Dim interval(fcount) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim item As PropertyItem = gif.GetPropertyItem(20736)
Dim index As Integer = 0
For i As Integer = 0 To gif.GetFrameCount(FrameDimension.Time) - 1
interval(i) = BitConverter.ToInt32(item.Value, index)
index += 4
Next
ShowGif()
' the timing interval storted in the GIF file is of the unit of
centi-second
Me.Timer1.Interval = interval(findex) * 10
Me.Timer1.Start()
End Sub
Dim findex As Integer = 0
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
findex += 1
If (findex = fcount) Then
findex = 0
End If
ShowGif()
Me.Timer1.Interval = interval(findex) * 10
End Sub
Private Sub ShowGif()
gif.SelectActiveFrame(FrameDimension.Time, findex)
Me.PictureBox1.Invalidate()
End Sub
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
e.Graphics.DrawImage(gif, New Point(0, 0))
End Sub
End Class
I display the GIF you provided using the above code and the animation on
the PictureBox is not slower than it is in IE.
Please try my sample code out on your side and let me know the result.
Sincerely,
Linda Liu
Microsoft Online Community Support
Hi Phil,
Have you tried my sample code out? How about the problem now?
If the problem is still not solved, please feel free to let me know.
Thank you for using our MSDN Managed Newsgroup Support Service!
Sincerely,
Linda Liu
Microsoft Online Community Support
>
Have you tried my sample code out?
Sorry, I have been away.
How about the problem now?
Yes, your code works very well The animated GIF displays correctly.
I added a second picture box and loaded the same image in normally, and it
is very clear that the default code in the picturebox control itself is
displaying the animation too slowly and is missing out frames. This would
definitely therefore appear to be a bug in the picturebox control, although
it is puzzling why other people don't see the same problem. I guess it must
be something to do with my hardware. If you'd like any extra information
about my PC set-up to help track down the error, please let me know.
Meanwhile I'll have a go at building your code into a new custom control,
that I can use in place of the picturebox whenever I need to display an
animated GIF.
Thanks,
Phil.
Hi Phil,
Thank you for your feedback! I am glad to hear that my code works on your
side.
I think also the problem may be specific to your hardware. You may have a
try on another PC to see if the problem still exists.
If convenience, please send me the information about your PC set-up and I
will record it in our internal database. It will definitely help to improve
our product. (To get my actual email, remove 'online' from my displayed
email address.)
We appreciate your contribution to our product!
Sincerely,
Linda Liu
Microsoft Online Community Support
>
If convenience, please send me the information about your PC set-up and I
will record it in our internal database. It will definitely help to
improve
our product. (To get my actual email, remove 'online' from my displayed
email address.)
System:
Microsoft Windows XP
Professional
Version 2002
Service Pack 2
Computer:
AMD Sempron(tm) Processor
3000+
1.81 GHz, 512 MB of RAM
Physical Address Extension
Display Adapter:
WinFast PX6200 TC
Monitor:
Ergovision 975TCO95
Display Properties
Screen resolution 128x1024
Color quality Highest (32 bit)
Advanced:
Normal size (96 DPI)
Screen refresh rate 85 Hertz
There is also a GeForce 6200 TurboCache tab which displays further nVidia
settings. I'm not sure if any of these may be relevant.
HTH
Phil.
Screen resolution 128x1024
Wow, that must be one narrow monitor.
:-)
Thanks,
Seth Rowe
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@l22g2000prc.googlegr oups.com...
>Screen resolution 128x1024
Wow, that must be one narrow monitor.
oops, should have been 1280 not 128 :-)
Hi Phil,
Thank you for your reply!
I will record this information in our inner database.
If you have any other question in the future, please don't hesitate to
contact us. It's our pleasure to be of assistance!
Have a nice day!
Sincerely,
Linda Liu
Microsoft Online Community Support This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: MrPickwick |
last post by:
Hi there.
If I place a picturebox on my form and load (at design time) an animated gif
into it, it shows and animates allright. If I load my animated gifs in an
Imagelist at design time and at...
|
by: GrandpaB |
last post by:
I am creating a small simulation in VB and wish to
incorporate several animated GIFS. I can load the GIFS
from the hard drive into a picture box and they animate,
but I have two questions.
1.)...
|
by: Dale Reed |
last post by:
Hi,
I have a button on an aspx page (I'm using vs2005 with asp2), which when
clicked takes a while to do some data processing before it posts back to the
screen to display the results.
I...
|
by: Helmut Giese |
last post by:
Hello out there,
this is OT but maybe some of you were in the past faced with the same
problem: I have lots of sequences of GIF files to combine into
animated GIFs. I can do it 'by hand' with...
|
by: Scirious |
last post by:
People, I need a way to detect the moment an animated GIF gets to it's end
to switch to a different GIF. I can't use a Timer because the GIFs have
different times and doing so (as I'm doing at the...
|
by: ZikO |
last post by:
Hi.
I am making a Multimedia Presentation in VB.NET 2005 and I have some
animated GIFs which I need to use. I tried to use PictureBox for it but it
doesn't play an animation in GIFs :/. What I...
|
by: Jeff |
last post by:
Hi,
I'd like to write Javascript that stops animated gifs from animating.
On Firefox, at least, window.stop(); does the trick, although it stops
everything on the page and is kind of...
|
by: helraizer1 |
last post by:
Hey,
I have a PHP script that I made for an image based shoutbox with emoticons. The problem is that php GD doesn't support animated gifs, yet perl GD does. How would I make it so that I could...
|
by: eneyardi |
last post by:
How to add gif image to startup screen?
I want to add gif image to my startup screen, is this possible that it may run as animated gif?
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
| |