alancc
alancc

Reputation: 811

Cannot play animated GIF in Delphi XE3?

I download a animated GIF file from enter image description here. The following the instructions in How to use Animated Gif in a delphi form to play it. But what I see is always a white block without any animation. Why?

Let me describe the process in details:

When I try to add the animated GIF, I see the following screen:

enter image description here

After clicking "OK" button, I will see below:

enter image description here

The whole project(Delphi 10.3) is at https://www.dropbox.com/s/jbsj86fgpq6qkpi/TestGIF.zip?dl=0

The related codeline is only below:

procedure TForm1.Button1Click(Sender: TObject);
begin
  (Image1.Picture.Graphic as TGIFImage).Animate := True;
( Image1.Picture.Graphic as TGIFImage ).AnimationSpeed:= 500;
end;

More information:

  1. I see Vcl.Imaging.GIFImg is added automatically after I set the picture to the GIF image.
  2. I cannot see the first frame in the designer, what I can see is a white block.
  3. I have tried other GIF images.For static images, they can be displayed properly. For animated GIF, when I load it, the Picture Editor will be able to show the first frame, but when I select "OK", the TImage will become a white block again.

Upvotes: 2

Views: 1106

Answers (1)

Tom Brunberg
Tom Brunberg

Reputation: 21045

It was not before I downloaded the image you referred to, that I could reproduce the problem.

The reason, (at least the only way I could reproduce the "error"), is that the TImage at the default designer size is 105 x 105, in which case it shows a part (top-left) of the image. The image is 630 x 637, and the visible part shown in the TImage is the top-left white area, where the spinner never draws.

The simple correction is to set the Proportional property True

Note also, that the picture editor window does scale the image to fit in its viewport.

Upvotes: 3

Related Questions