在delphi 2009中创建一个gif动画文件?

isa*_*isa 5 delphi delphi-2009

gif := TgifImage.Create;
gif.Width := 100;
gif.Height := 100;
gif.AnimationSpeed := 500;
gif.Animate := true;
gif.add(image1.Picture.Bitmap);
gif.add(image2.Picture.Bitmap);
gif.add(image3.Picture.Bitmap);
gif.SaveToFile('gif.gif');
Run Code Online (Sandbox Code Playgroud)

这只循环一次,速度不是500?

如何让它循环并设置速度?

stu*_*lly 6

编写原始TGIFImage的 Anders Melander 有以下答案.

您需要在GIF的第一帧添加"Netscape Loop"扩展块.循环块必须是您为框架定义的第一个扩展,否则它将无法工作.

有关如何构建动画GIF的示例,请参阅Animate演示.

以下是Animate演示的代码摘录:

// Add the source image to the animation
Result := GIF.Add(Source);

// Netscape Loop extension must be the first extension in the first frame!
if (GIF.Images.Count = 1) then
begin
  LoopExt := TGIFAppExtNSLoop.Create(Result);
  LoopExt.Loops := 0; // Number of loops (0 = forever)
end;
Run Code Online (Sandbox Code Playgroud)

您可以在此处查看TGIFImage文档.


vol*_*vox -1

至少需要一个定时器和一些无闪烁的方法。

请参阅 RXLibrary 中 rxAnimate.pas 单元中的示例(免费提供。来源位于 SourceForge.net 或http://www.dummzeuch.de/delphi/english.html)。

JVCL 也有类似组件的来源。