2

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.
alancc
  • 487
  • 2
  • 24
  • 68
  • It works for me in 10.3. I assume you also read the comments to the A you link to and have made sure you don't have the JVCL issue. – Andreas Rejbrand Dec 05 '20 at 23:59
  • I try in 10.3 but also failed. I do not have JVCL installed. – alancc Dec 06 '20 at 07:14
  • @AndreasRejbrand, I try XE3, 10.3 and 10.2 on computers without any additional VCL installed. But all failed. – alancc Dec 06 '20 at 08:10
  • Which unit do you have in the `uses` to show the gifs? Obviously you load the image at design time. Do you see the first frame while in the designer? Have you tried with other .gif images? – Tom Brunberg Dec 06 '20 at 09:03
  • @TomBrunberg, I see Vcl.Imaging.GIFImg is added automatically after I set the picture to the GIF image. I cannot see the first frame in the designer, what I can see is a white block. 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. – alancc Dec 06 '20 at 12:02
  • Thanks, what if you try with a completely **new application**. New project, add `TImage` and then from properties, `Picture`, `...`, `Load...` and after selecting a gif file, finally OK. Then run. – Tom Brunberg Dec 06 '20 at 12:19
  • Oh, I forgot. Also add a `TButton` and the ` (Image1.Picture.Graphic as TGIFImage).Animate := True;` to the button's `OnClick` – Tom Brunberg Dec 06 '20 at 12:29
  • @TomBrunberg, Yes, I just do in that way. I have added more info to my question accordingly. – alancc Dec 06 '20 at 23:06

1 Answers1

3

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.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54