在DELPHI中显示GIF动画


本文整理自网络,侵删。

 想没想过在DELPHI中显示GIF动画?Delphi的用户是非常幸运的,因为有免费控件可以使用。最著名的控件是Anders Melander编写的TGifImage,并提供完整的源程序。它原来的主页是www.melander.dk/delphi/gifimage/,不过有很长时间没有更新了。如果要在新版本的Delphi中使用,可以从http://finn.mobilixnet.dk/delphi/下载Finn Tolderlund改写的Delphi 5/6/7版本的TGifImage。 现在看看怎么在DELPHI中使用GIFImage.pas文件,显示GIF动画首先,新建一个工程,在Project-OPTIONS菜单中的Directories/Conditionals页中的search中添加一个路径,这个路径指向GIFImage.pas所在文件夹然后在FORM1的PUBLIC区添加一个变量GIF,定义为TGIFImage类型在form1的onCreate中添加代码:GIF := TGIFImage.Create; 在form1上添加一个按钮button1,添加一个image控件在button1的click事件中添加代码: Gif.LoadFromFile('d:\abc.gif'); GIF.Paint(Image1.Canvas,Image1.ClientRect,[goAsync,goLoop,goAnimate]); 



unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,GIFImage, ExtCtrls;

type
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
Panel1: TPanel;
Image2: TImage;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
i:integer;
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
gif:TGIFImage;
gif1:TGIFImage;
begin
//include(GIFImageDefaultDrawOptions, goDirectDraw);
gif:=TGIFImage.Create;
gif1:=TGIFImage.Create;
gif.LoadFromFile('test.gif');
gif1.LoadFromFile('test.gif');
try
GIF.Paint(Image1.Canvas,Image1.ClientRect,[goTransparent,goDither,goAsync,goLoop,goAnimate,goDirectDraw]);
GIF1.Paint(Image2.Canvas,Image2.ClientRect,[goTransparent,goAsync,goLoop,goAnimate]);

//Image1.Picture.Assign(gif);
//include(GIFImageDefaultDrawOptions, goDirectDraw);
//Image2.Picture.Assign(gif1);
finally
//GIF.Free;
//gif1.Free;
end;

end;

procedure TForm1.Timer1Timer(Sender: TObject);

begin
//gif.PaintStart;
//image1.Picture.Assign(gif.Bitmap);
//Image1.Repaint;
// if (i<(gif.Images.Count-1)) then Inc(i) else i:=0;

end;

end.


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/swei315/archive/2010/04/13/5483027.aspx

相关阅读 >>

Delphi获取文件大小

Delphi memo 滚动条 自动滚到最后一行

Delphi获取进程和模块信息

Delphi一个综合实用的单元

Delphi获取身份证号码验证码算法

Delphi 透明窗体

Delphi检查自身是否被调试

Delphi 10.3.3 启动cnpack ide 专家 cnwizards coreide260.bpl错误解决办法

Delphi判断ip地址是否正确

Delphi 2010 域名转换ip

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...