How do I make the Timage component in Delphi 2007 show a GIF animation?

I understnd that the Timage component in Delphi 2007 incorporates Melander's TGIFimage functionality - and I thought that his component would display GIF animation.  But when I load an animated GIF into Timage in Delphi 2007 it shows but does not animate.

I've tried search through the properties for some cllue but to no anail.

Does someone know how to get an animated GIF to work in Delphi 2007?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I cannot tell you how to make a TImage animate a gif, but can advise you that all the work is done and source available in the RXGifAnimator and The JVGifAnimator.

Both are part of complete VCL libraries. RXLib has quite a few ports and some are available on and it is also part of the Jedi VCL also available on sourceforge.

I have used both and they work well.

Maybe this can help you.

DMTrumpAuthor Commented:

Those are good leads - and I may have to resort to that - but Anders Melanders TGIFimage, I thought, when it was available for older Delphi, would display animated GIFs.  Now he says that he donated it to CodeGear and that it's built into Timage!  Surely they didn't strip out animation!?
Hmmm.. I never could make a gif animated in a TImage in D7 or any other. Display them, I think, but I had to use the RX or Jedi comp. to animate a gif.

Guess I need to try it....

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Nope... nothing in D7 that I can find for Gif... but here is some more info...

TGIFImage[1] - free with source (a version of Anders Melander's TGIFImage ported to Delphi 7). Full TGraphic implementation of the GIF graphics format. Reads, writes and displays animated and transparent GIFs and can convert to and from any format supported by TGraphic (e.g TBitmap, TJPEGImage, TIcon, TMetaFile etc.). Implements the complete GIF87a and GIF89a specification and most common GIF extensions. Advanced features include:

    * Integrates with TPicture to add GIF support to the TImage, TOpenPictureDialog and TSavePictureDialog components. Also works at design time.
    * Imports images with more than 256 colors using color quantization and 6 different dithering methods (e.g. floyd s!teinberg).
    * Multi threaded drawing engine.
    * GIF optimizer reduces the size of your GIFs.
    * GIF to AVI and AVI to GIF converter.


GraphicsEX which I like a lot:

GraphicEx image library - an addendum to Delphi's Graphics.pas to enable your application to load many common image formats. This library is primarily designed to load images as background (buttons, forms, toolbars) and textures (DirectX, OpenGL) or for image browsing and editing purposes as long as you don't need to save images. Currently only TTargaGraphic also supports saving an image. GraphicEx is open source under the Mozilla Public License (MPL).


All info from

GraphicsEx is really great for a bunch of different file formats.

Dagan HooverDeveloperCommented:
I once resorted to cutting up a .gif into bmps and loading them into a TImageList. Then using a timer to animate. That was a last resort though.
DMTrumpAuthor Commented:
I've looked at the JVCL but adding 600 components to my pallette seems like a terrifying thing to do.  I already have trouble finding components in the list!  I wish you could search for them.  I've got TMS and several other large sets loaded and its just a real PITA to find anything anymore.  
Jedi is huge!!!

Check out the links above for the Aners code and GraphicsEx

DMTrumpAuthor Commented:
Somehow the discussion seems to have drifted to the thinking that I'm using D7 - nope - I'm using Delphi 2007 - and it's "supposed" to support everything that was in Melanders TGIFimage!
SOrry about that.... Not sure how I spaced that as it is clear as a bell in your Q! I can check that later and let you know, as I don't have D2007 on in front of me now.

Have you installed all the latest updates?

If GraphicsEx is D2007 compatible it is still good.

DMTrumpAuthor Commented:
from "" this information direct from Anders Melander
The former home of TGIFImage for Delphi

This is a blind page for old incoming links to the former TGIFImage page.

I have donated TGIFImage to CodeGear and do not support it anymore. Sorry.
Where to get TGIFImage then?

The official TGIFImage version 2.2 release is available from a lot of places on the net. However since that release hasnt been maintained since I released it in May 1999, I strongly suggest you use one of the following releases instead.
Version 2.2

For an updated TGIFImage version 2.2, supporting Delphi 5-2007, please go to Finn Tolderlunds web site.

Finn has been maintaining TGIFImage on his own since my former web site disappeared. His version is based on the official TGIFImage version 2.2 release.
In addition to the updated sources, I recommend you also get the version 2.2 installation kit (also available from Finns site), since that contains the documentation and all the demos.
Version 3.0

For TGIFImage version 3.0, supporting Delphi 2007, please purchase Delphi 2007.

Version 3.0 is based on version 2.3, a version that was never released. It differs from version 2.2 in the following way:
It is drop-in compatible with earlier version if one doesnt use the TGIFImage class directly.
E.g. if you just use TImage to display GIFs, then you should be fine.
Many classes have been renamed for better consistency.
The rendering engine has been completely rewritten.
Support for earlier versions of Delphi has been removed.
The tiling feature has been removed from the TImage rendering.
The low level rendering engine still supports it though.
Most of the options that were previously controlled with conditional defines (i.e. compile time options) are now controlled with variables (i.e. run time options).

Since CodeGear didnt include any of the demos I wrote for version 3.0, you might want to grab a copy of the version 2.2 installation too. Although the demos wont run with version 3.0 and most of the documentation is obsolete, its better than nothing.
Search your CodeGear D2007 directory for GifImage.pas.

Should be bthere and most likly they shipped it as an add in component.

You will need that in your uses or install it as a component. Not sure yet,

DMTrumpAuthor Commented:
I think I'm up to date - but I'll check.

FYI GraphicEX is listed as being compatible through D7 and it supports a lot of things I have no use for, so I'm going to check it out only as a last resort.

I <could> use the slice and dice technique - divide the animation up into 25 chunks and use a timer load as TheivingSix mentioned.  But that seems like a waste if there's a way to do it in TImage as is.

This sentence from Melanders page my be a clue:
"Most of the options that were previously controlled with conditional defines (i.e. compile time options) are now controlled with variables (i.e. run time options)."
DMTrumpAuthor Commented:
GIFImg got added to my uses clause already - evidently when I loaded a GIF into Timage.picture.  So there's still something I'm not doing right <OR> GIFimg 3.0 as used by CodeGear doesn't support animation like the older versions from Melander.

I had used Melanders component way back in D5, but had never needed an animation.

Here ya go....


PS. I used a gif from my icon directory.
unit Unit1;
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, GIFImg;
  TForm1 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    { Public declarations }
  Form1: TForm1;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
  MyGifImage : TGifImage;
 MyGifImage := TGifImage.Create;
 MyGifImage.Animate := True;

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DMTrumpAuthor Commented:
Thanks for all the work you put into this - I really appreciate it!

I'll load my image from a resource stream and all will be well!
As you've discovered I chose to disable animation by default. The primary cause was that I judged that the average user wouldn't want (or expect) animated content in TImage as no other TGraphic descendants support it.

Anyhow, to enable GIF animation globally just set the GIFImageDefaultAnimate global variable to True:

  GIFImageDefaultAnimate := True;

and then load the GIF into your TImage as usual.

You can do the same for transparency with the GIFImageDefaultTransparent global variable:

  GIFImageDefaultTransparent := True;

If your GIF is both transparent and animated you should double buffer the parent of the TImage control to avoid flickering. E.g. by placing the TImage on a TPanel and setting the panel's DoubleBuffered property to True.
DMTrumpAuthor Commented:
Thank you Anders!  Adding your GIFimage component to D2007 was nice, but once agin, they (CodeGear) gets a D grade on documentation!  <LOL>
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.