Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animated GIF and TDrawgrid in Delphi 2007

I am being able to draw the image using something like the code below:

ACanvas.Draw(ARect.Left+16, ARect.Top+4, imgGIF.Picture.Graphic )

Now the gif for that imgGIF component is being loaded via

  GIF := TGifImage.Create;
  GIF.LoadFromFile('path\to\gif\processing.gif');
  GIF.Animate := True;
  imgGIF.Picture.Graphic.Assign(GIF);

I am setting

GIFImageDefaultAnimate := True;
GIFImageDefaultTransparent := True;

The environment is Delphi 2007, using the TGifImage that comes with the Delphi 2007 DVD. Is this even possible? To display an animated GIF on a TDrawgrid Cell?

I don't think it is since canvas.draw is only drawing the image, not inserting the component into the cell - so as far as I can understand, it is only drawing the firm image on the gif.

like image 824
ronaldosantana Avatar asked Nov 29 '25 15:11

ronaldosantana


1 Answers

When TGIFImage.Animate is set to True, calling Canvas.Draw() will render the current frame of the animation. When the TGIFImage is placed inside a TImage, TImage uses the TGraphic.OnChange event to automatically redraw the latest frame as the animation is running. To do the same thing with the TDrawGrid, you will have to call Canvas.Draw() periodically, such as in a timer whose interval is set to the value of the TGIFImage.FrameDelay property. Otherwise, load the GIF image into a separate TGIFImage instance for the TDrawGrid's use so you can utilize the TGraphic.OnChange event.

like image 133
Remy Lebeau Avatar answered Dec 01 '25 09:12

Remy Lebeau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!