473,387 Members | 1,844 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,387 software developers and data experts.

ImageList and animated Gifs

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 runtime copy the image from the list into a
PictureBox using "MyPictureBox.Image = MyImageList.Images(n)" it will only
show the first frame and not animate at all.
Does this not work at all? Are there alternatives?

Thanks and regards
Nov 20 '05 #1
4 7810
store the image as an embedded resource it's pretty much what image list
does anyways. then access it similar to this

dim bmp as bitmap = new
Drawing.Bitmap(gettype(classname).Assembly.GetMani festResourceStream("Namesp
ace.FileName.BMP")

(didnt verify the class names so that might be a little off)
"MrPickwick" <td*@odic.tc> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl...
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 runtime copy the image from the list into a PictureBox using "MyPictureBox.Image = MyImageList.Images(n)" it will only
show the first frame and not animate at all.
Does this not work at all? Are there alternatives?

Thanks and regards

Nov 20 '05 #2
store the image as an embedded resource it's pretty much what image list
does anyways. then access it similar to this

dim bmp as bitmap = new
Drawing.Bitmap(gettype(classname).Assembly.GetMani festResourceStream("Namesp
ace.FileName.BMP")

(didnt verify the class names so that might be a little off)
"MrPickwick" <td*@odic.tc> wrote in message
news:eP**************@TK2MSFTNGP11.phx.gbl...
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 runtime copy the image from the list into a PictureBox using "MyPictureBox.Image = MyImageList.Images(n)" it will only
show the first frame and not animate at all.
Does this not work at all? Are there alternatives?

Thanks and regards

Nov 20 '05 #3
Hi,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to stored a list of
animated gif into an imagelist and use the picturebox to show the picture
in the imagelist.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think ImageList did not support the animated gif so far. To wordaround
the problem, I think in the IDE we can add the GIFs to the project and
changed their "Build Action" property to "Embedded Resource". Then we can
read them out into an arraylist and use them similar as the imagelist.
Here goes the code.
'I add a test.gif into the project.

Dim pics As ArrayList
Dim imgStream As Stream = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
pics = New ArrayList
Dim bmp As Bitmap = Nothing
' get a reference to the current assembly
Dim a As [Assembly] = [Assembly].GetExecutingAssembly()
' get a list of resource names from the manifest
Dim resNames As String() = a.GetManifestResourceNames()
Dim s As String
For Each s In resNames
If s.EndsWith(".gif") Then
' attach to stream to the resource in the manifest
imgStream = a.GetManifestResourceStream(s)
If Not imgStream Is Nothing Then
' create a new bitmap from this stream and
' add it to the arraylist
bmp = Image.FromStream(imgStream) '
If Not bmp Is Nothing Then
pics.Add(bmp)
End If
bmp = Nothing
End If
End If
Next s
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.PictureBox1.Image = pics(0)
End Sub

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
imgStream.Close()
imgStream = Nothing
End Sub

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
Hi,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to stored a list of
animated gif into an imagelist and use the picturebox to show the picture
in the imagelist.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think ImageList did not support the animated gif so far. To wordaround
the problem, I think in the IDE we can add the GIFs to the project and
changed their "Build Action" property to "Embedded Resource". Then we can
read them out into an arraylist and use them similar as the imagelist.
Here goes the code.
'I add a test.gif into the project.

Dim pics As ArrayList
Dim imgStream As Stream = Nothing
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
pics = New ArrayList
Dim bmp As Bitmap = Nothing
' get a reference to the current assembly
Dim a As [Assembly] = [Assembly].GetExecutingAssembly()
' get a list of resource names from the manifest
Dim resNames As String() = a.GetManifestResourceNames()
Dim s As String
For Each s In resNames
If s.EndsWith(".gif") Then
' attach to stream to the resource in the manifest
imgStream = a.GetManifestResourceStream(s)
If Not imgStream Is Nothing Then
' create a new bitmap from this stream and
' add it to the arraylist
bmp = Image.FromStream(imgStream) '
If Not bmp Is Nothing Then
pics.Add(bmp)
End If
bmp = Nothing
End If
End If
Next s
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.PictureBox1.Image = pics(0)
End Sub

Private Sub Form1_Closed(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Closed
imgStream.Close()
imgStream = Nothing
End Sub

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John J. Hughes II | last post by:
Is it possible using Image or Bitmap to build and save an animated GIF file? I am not have a problem saving the GIF file just getting the frames added to it. I did find ImageAnimator but it only...
2
by: Koen Hoorelbeke | last post by:
Hi there, I'm trying to read an animated gif from a url (for a banner-rotator). The code I have now, does read the gif (or jpg), but the result is that I only get the first frame of the animated...
0
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...
4
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...
2
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...
3
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...
4
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...
27
by: Phil | last post by:
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.