窗体上放有一个image并设置显示为false,想在窗体显示时实现百叶窗效果
procedure TForm1.Button1Click(Sender: TObject);
var
newbmp: TBitmap;
i,j,bmpheight,bmpwidth:integer;
xgroup,xcount:integer;
begin
newbmp:= TBitmap.Create;
newbmp.Width:=image1.Width;
newbmp.Height:=image1.Height;
bmpheight:=image1.Height;
bmpwidth:=image1.Width;
//百叶窗效果
xgroup:=16;
xcount:=bmpheight div xgroup;
for i:=0 to xcount do
for j:=0 to xgroup do
begin
newbmp.Canvas.CopyRect(Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i),
image1.Canvas,Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i));
form1.Canvas.Draw(0,0,newbmp);
end;
newbmp.free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
newbmp: TBitmap;
i,j,bmpheight,bmpwidth:integer;
xgroup,xcount:integer;
begin
newbmp:= TBitmap.Create;
newbmp.Width:=image1.Width;
newbmp.Height:=image1.Height;
bmpheight:=image1.Height;
bmpwidth:=image1.Width;
//百叶窗效果
xgroup:=16;
xcount:=bmpheight div xgroup;
for i:=0 to xcount do
for j:=0 to xgroup do
begin
newbmp.Canvas.CopyRect(Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i),
image1.Canvas,Rect(0,xcount*j+i-1,bmpwidth,xcount*j+i));
form1.Canvas.Draw(0,0,newbmp);
end;
newbmp.free;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货