-1

I want to know how is it possible to animate gif image that is put in TImageList.

I know that if we could access the graphic of each images in TImageList it may be possible cast the graphic of the picture to TGIFImage and set Animate property to true. but the problem is how can we access the image that is loaded in TImageList and cast it to TGIFImage and set that animate property?

EDIT:

How we can have animated gif in TTreeView?

As David Heffernan answered TImageList is not appropriate for saving gif images. but the purpose of this question was to have an animated gif in a treeview. By the suggestion of Remy-lebeau I wrote a unit for that. In this unit I defined two classes. first TGifImageRefrence that uses a TImagelist as its property and must be assigned and has a procedure that add gif image to this imagelist. each frame will be saved as single image in Imagelist and frames' indexes and animationspeed will be saved. The Second class is TGifNode that its purpose is to be a node in TreeView. It contains a timer an accept a TGifImageRefrence as it's property. you can inherit a class for your own node for your treeview from this class. I write an example using this unit and put them together and you can download it from http://loghman.ir/MySource/GifInTreeView.zip

Loghman
  • 1,500
  • 1
  • 14
  • 30

1 Answers1

3

A TImageList stores a list of equally sized static images. It's not appropriate for hosting an animated GIF. You could unpack all the images from the animated GIF and put them in the images list. And then reconstruct them later for animation. That would seem pointless. You should use TGIFImage for animating a GIF.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • I want do this because I wanted to have a TreeView that contain some images that blinks. some of those treenodes needed to alert the user. – Loghman Nov 02 '13 at 11:29
  • 4
    Well, I guess you'll need to find a different solution to that problem. But you cannot put an animated GIF in an image list, set the image index of a node in your tree and hope that it will animate. Not going to happen. – David Heffernan Nov 02 '13 at 11:33
  • 3
    You can, however, put the individual frames as separate images in an ImageList, and then use a timer to change a node's image index every few seconds to loop through the ImageList, giving the appearance of animation. – Remy Lebeau Nov 02 '13 at 16:55
  • @RemyLebeau Thanks for the suggestion. I wrote a unit for this purpose. anyone like to have animated gif in his TreeView may use it. http://loghman.ir/MySource/GifInTreeView.zip I realy don't udnerstand why someone who don't know the answer put minus on my question. realy interesting! :)) – Loghman Nov 03 '13 at 13:16
  • @Loghman I'm guessing you were downvoted because your question didn't ask about your actual problem, but rather about how to get your ill-suited attempt at a solution working. I've balanced it out. I also suggest that in future it may help if you state your actual problem and what you tried to solve it. – Disillusioned May 21 '14 at 14:22
  • @CraigYoung yes. true. one of my problems is how to ask a question. after this question I tried to be more cautious. thank you for your goodwill. – Loghman May 22 '14 at 08:56