假设图片存于一个TImagelist中, 显示效果在个TBitmap中:
var
BeginY: Integer;
currentId: Integer;
CurrentStep: Integer;
// 初始化
procedure TForm1.......
begin
BeginY := -imagelist1.height;
currentId := 0;
currentstep := imagelist1.height;
end;
procedure TForm1.Timer1OnTimer(Sender: TObject);
var
bmp, bmp1: TBitmap;
begin
if not assigned(image1.picture.bitmap) then
begin
image1.picture.bitmap := tbitmap.create;
image1.picture.bitmap.width := image1.width;
image1.picture.bitmap.height := image1.height;
end;
bmp1 := tbitmap.create;
imagelist1.getbitmap(currentid, bmp1);
bmp := tbitmap.create;
bmp.width := image1.width;
bmp.height := image1.height;
bmp.canvas.draw(0, currenty+step, image1.picture.graphic);
bmp.canvas.copyrect(rect(0, currenty, imagelist1.width, currenty + imagelist1.height),
bmp1.canvas, rect(0, 0, bmp1.width, bmp1.height));
image1.picture.bitmap.assign(bmp);
bmp.free;
bmp1.free;
currenty := currenty + step;
if currenty + imagelist1.height >= 0 then
begin
currentid := currentid + 1;
if currentid >= imagelist1.count then
currentid := 0;
currenty := currenty - imagelist1.height;
end;
if 特定条件 then
begin
step := step - 5;
if step <= 0 then
begin
timer1.enabled := false;
Timer1OnTimer(Sender);
end;
end;
end;