procedure TForm2.Button1Click(Sender: TObject);
begin
if(OpenDialog1.Execute)then
begin
Edit1.Text:=OpenDialog1.FileName;
sFileName:=Edit1.Text;
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
Bitmap1:=TBitmap.Create;
Bitmap1.LoadFromFile(sFileName);
Delta:=Bitmap1.Width/distance;
for I:=0 to Distance do
begin
MidVar:=Round(Delta*I);
with srcRect do
begin
Left:=Bitmap1.Width-MidVar;
top:=0;
Right:=Bitmap1.Width;
Bottom:=Bitmap1.Height;
end;
with destRect do
begin
Left:=X0;
top:=Y0;
Right:=X0+MidVar;
Bottom:=Y0+Bitmap1.Height;
end;
Canvas.CopyRect(destRect,Bitmap1.canvas,srcRect);
end;
Bitmap1.Free;
end;
Delphi中实现位图的拷贝有三种方法:
1、TCanvas 对象中的CopyRect方法
2、Windows API 的Bitblt函数
3、运行时动态改变Timage的Top和Left等属性