代码如下
rocedure BmpMoveToImages(image1:Timage);
var
I:Integer;
bmp:Tbitmap;
Dest,Source: TRect;
Bmpcolwidth,Imagecolwidth:Integer;
Bmpcolheight,Imagecolheight:Integer;
begin
bmp:=Tbitmap.Create ;
Try
Bmp.Width:=100;
Bmp.Height:=100;
bmp.LoadFromFile('c:/windows/circles.bmp');
//假设图框的宽.高均能被10整除
Bmpcolwidth:=bmp.Width div 10;
Bmpcolheight:=bmp.Height ;
imagecolwidth:=image1.Width div 10;
Imagecolheight:=image1.Height ;
For i:=1 to 10 Do
Begin
Sleep(1000);
Dest:=Rect((i-1)*imagecolwidth,0,i*imagecolwidth,imagecolHeight);
Source:=Rect((i-1)*Bmpcolwidth,0,i*bmpcolwidth,BmpcolHeight);
Form1.Image1.Canvas.CopyRect(dest,bmp.Canvas,source);
image1.Refresh;
End;
Finally
bmp.Free ;
End;
end;