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?
DMTrumpAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
JohnjcesConnect With a Mentor Commented:
Here ya go....

John

PS. I used a gif from my icon directory.
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, GIFImg;
 
type
  TForm1 = class(TForm)
    Image1: TImage;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
var
  MyGifImage : TGifImage;
begin
 MyGifImage := TGifImage.Create;
 MyGifImage.LoadFromFile('C:\Icons\Bitmaps\Animations\Blop.gif');
 MyGifImage.Animate := True;
 Image1.Picture.Graphic.Assign(MyGifImage);
end;
 
end.

Open in new window

0
 
JohnjcesCommented:
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 SourceForge.net 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.

John
0
 
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!?
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 
JohnjcesCommented:
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....

John
0
 
JohnjcesCommented:
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.

Download:http://finn.mobilixnet.dk/delphi/

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).

Download: http://delphi.about.com/gi/dynamic/offsite.htm?zi=1/XJ&sdn=delphi&cdn=compute&tm=173&f=22&su=p284.8.150.ip_&tt=2&bt=0&bts=0&zu=http%3A//www.soft-gems.net/Graphics.php

All info from Delphi.About.com.

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

John
0
 
ThievingSixCommented:
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.
0
 
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.  
0
 
JohnjcesCommented:
Jedi is huge!!!

Check out the links above for the Aners code and GraphicsEx


John
0
 
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!
0
 
JohnjcesCommented:
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.

John
0
 
DMTrumpAuthor Commented:
from "http://www.melander.dk/delphi/gifimage/" 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.
0
 
JohnjcesCommented:
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,

John
0
 
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)."
0
 
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.

0
 
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!
0
 
anmeCommented:
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.
0
 
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>
0
All Courses

From novice to tech pro — start learning today.