delphi显示 jpg、png、gif 图片及 gif 动画的方法
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses jpeg, GIFImg, pngimage;
{显示 jpg 图片}
procedure TForm1.Button1Click(Sender: TObject);
var
jpg: TJPEGImage;
begin
jpg := TJPEGImage.Create;
jpg.LoadfromFile('C:\Temp\Test.jpg');
Canvas.Draw(0, 0, jpg);
jpg.Free;
end;
{显示 png 图片}
procedure TForm1.Button2Click(Sender: TObject);
var
png: TPngImage;
begin
png := TPngImage.Create;
png.LoadfromFile('C:\Temp\Test.png');
Canvas.Draw(0, 0, png);
png.Free;
end;
{显示 gif 图片}
procedure TForm1.Button3Click(Sender: TObject);
var
gif: TGIFImage;
begin
gif := TGIFImage.Create;
gif.LoadfromFile('C:\Temp\Test.gif');
Canvas.Draw(0, 0, gif);
gif.Free;
end;
{显示 gif 动画}
procedure TForm1.Button4Click(Sender: TObject);
var
gif: TGIFImage;
begin
gif := TGIFImage.Create;
gif.LoadfromFile('C:\Temp\Test.gif');
gif.Animate := True;
with TImage.Create(Self) do begin
Parent := Self;
Left := 0;
Top := 0;
Picture.Assign(gif);
end;
gif.Free;
end;
end.
相关文档:
首先用Notepad或Resource workshop 4.5建立RC文件。 结构如下 /****************************************************************************
rcdemo.rc
produced by Borland Resource Workshop
*****************************************************************************/
# ......
1.防止刷新时闪烁的终极解决办法
{ 防止刷新时闪烁的终极解决办法(对付双缓冲无效时) }
Perform($000B, 0, 0); //锁屏幕 防止闪烁
// 做一些会发生严重闪烁的事情..
//解锁屏幕并重画
Perform($000B, 1, 0);
& ......
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure Butt ......
1.调用API函数
procedure CopyFile(fromFileName,ToFileName:string);
var
f1,f2:file;
Begin
AssignFile(f1,fromFileName); file://指定源文件名
AssignFile(f2,ToFileName); file://指定目标文件名
Reset(f1);
Try
Rewrite(f2);
Try
If Lzcopy(TfileRec(f1).handle,TfileRec(f2).Handle)<0
Then
Raise ......
在Delphi中,通常可以用以下三种方法来实现程序的延时,即TTtimer控件,Sleep函数,GetTickCount函数。但是其精度是各不相同的。
一、三种方法的简单介绍
1)TTtimer控件
TTtimer控件的实质是调用Windows API定时函数SetTimer和KillTimer来实现的,并简化了对WM_TIMER 消息的处理过程。通过设置OnTimer事
件和Inte ......