图形特效 一

                            { 从单个边逐渐显示图像效果
   输入参数:
     Image       要进行推拉特效的TImage
     Direction   方向
     SleepTime   特效的快慢控制
}
procedure Img_SilBorderExpand(Image:TImage;Direction,SleepTime:Word);
var
i,BmpHeight,BmpWidth:Integer;
OldBmp:TBitmap;
begin
OldBmp:=TBitmap.Create;
OldBmp.Assign(Image.Picture.Graphic);
Image.Picture:=nil;
BmpHeight:=OldBmp.Height;
BmpWidth:=OldBmp.Width;
try
 case Direction of
  fromBottomBorder :begin
                     for i:=0 to BmpHeight do
                     begin
                      Image.Canvas.CopyRect(Rect(0,BmpHeight-i,BmpWidth,BmpHeight),
                                            OldBmp.Canvas,
                                            Rect(0,BmpHeight-i,BmpWidth,BmpHeight)); 
                      Image.Refresh;
                      Sleep(SleepTime);
                     end;
                    end;
  fromTopBorder :begin
                  for i:=0 to BmpHeight do
                  begin
                   Image.Canvas.CopyRect(Rect(0,0,BmpWidth,i),
                                         OldBmp.Canvas,
                                         Rect(0,0,BmpWidth,i));
                   Image.Refresh;
                   Sleep(SleepTime);
                  end;
                 end;
  fromLeftBorder :begin
                   for i:=0 to BmpWidth do
                   begin
                    Image.Canvas.CopyRect(Rect(0,0,i,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(0,0,i,BmpHeight));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
  fromRightBorder :begin
                   for i:=0 to BmpWidth do
                   begin
                   Image.Canvas.CopyRect(Rect(BmpWidth-i,0,BmpWidth,BmpHeight),
                                         OldBmp.Canvas,
                                         Rect(BmpWidth-i,0,BmpWidth,BmpHeight));
                   Image.Refresh;
                   Sleep(SleepTime);
                  end;
                 end;
  else Image.Picture.Bitmap.Assign(OldBmp);
 end;
finally
 OldBmp.Free;
end;
end;



{ 从单个边推拉显示图像效果
   输入参数:
     Image       要进行推拉特效的TImage
     Direction   方向
     SleepTime   特效的快慢控制
}
procedure Img_SilBorderPush(Image:TImage;Direction,SleepTime:Word);
var
i,BmpHeight,BmpWidth:Integer;
OldBmp:TBitmap;
begin
OldBmp:=TBitmap.Create;
OldBmp.Assign(Image.Picture.Graphic);
Image.Picture:=nil;
BmpHeight:=OldBmp.Height;
BmpWidth:=OldBmp.Width;
try
 case Direction of
  fromBottomBorder :begin
                     for i:=0 to BmpHeight do
                     begin
                      Image.Canvas.CopyRect(Rect(0,BmpHeight-i,BmpWidth,BmpHeight),
                                            OldBmp.Canvas,
                                            Rect(0,0,BmpWidth,i)); 
                      Image.Refresh;
                      Sleep(SleepTime);
                     end;
                    end;
  fromTopBorder :begin
                  for i:=0 to BmpHeight do
                  begin
                   Image.Canvas.CopyRect(Rect(0,0,BmpWidth,i),
                                         OldBmp.Canvas,
                                         Rect(0,BmpHeight-i,BmpWidth,BmpHeight));
                   Image.Refresh;
                   Sleep(SleepTime);
                  end;
                 end;
  fromLeftBorder :begin
                   for i:=0 to BmpWidth do
                   begin
                    Image.Canvas.CopyRect(Rect(0,0,i,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(BmpWidth-i,0,BmpWidth,BmpHeight));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
  fromRightBorder :begin
                    for i:=0 to BmpWidth do
                    begin
                     Image.Canvas.CopyRect(Rect(BmpWidth-i,0,BmpWidth,BmpHeight),
                                           OldBmp.Canvas,
                                           Rect(0,0,i,BmpHeight));
                     Image.Refresh;
                     Sleep(SleepTime);
                    end;
                   end;
  else Image.Picture.Bitmap.Assign(OldBmp);
 end;
finally
 OldBmp.Free;
end;
end;



{ 从中间向对边逐渐显示图像效果
   输入参数:
     Image       要进行特效的TImage
     Direction   方向
     SleepTime   特效的快慢控制
}
procedure Img_CenterToDulBorderExpand(Image:TImage;Direction,SleepTime:Word);
var
OldBmp:TBItmap;
i,BmpWidth,BmpHeight:Integer;
Center:Integer;
begin
OldBmp:=TBitmap.Create;
try
 OldBmp.Assign(Image.Picture.Graphic);
 Image.Picture:=nil;
 BmpWidth:=OldBmp.Width;
 BmpHeight:=OldBmp.Height;
 case Direction of
  horizontalShow :begin
                   Center:=BmpWidth div 2;
                   for i:=0 to Center do
                   begin
                    Image.Canvas.CopyRect(Rect(Center-i,0,Center+i,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(Center-i,0,Center+i,BmpHeight));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
  verticalShow :begin
                 Center:=BmpHeight div 2;
                 for i:=0 to Center do
                 begin
                  Image.Canvas.CopyRect(Rect(0,Center-i,BMpWidth,Center+i),
                                        OldBmp.Canvas,
                                        Rect(0,Center-i,BMpWidth,Center+i));
                  Image.Refresh;
                  Sleep(SleepTime);
                 end;
                end;
 end;
 Image.Canvas.CopyRect(Rect(0,0,BmpWidth,BmpHeight),
                       OldBmp.Canvas,
                       Rect(0,0,BmpWidth,BmpHeight));
finally
 OldBmp.Free;
end;
end;


{ 从对边向中间逐渐显示图像效果
   输入参数:
     Image       要进行特效的TImage
     Direction   方向
     SleepTime   特效的快慢控制
}
procedure Img_DulBorderToCenterExpand(Image:TImage;Direction,SleepTime:Word);
var
OldBmp:TBItmap;
i,BmpWidth,BmpHeight:Integer;
Count:Integer;
begin
OldBmp:=TBitmap.Create;
try
 OldBmp.Assign(Image.Picture.Graphic);
 Image.Picture:=nil;
 BmpWidth:=OldBmp.Width;
 BmpHeight:=OldBmp.Height;
 case Direction of
  verticalShow :begin
                 Count:=BmpHeight div 2;
                 for i:=0 to Count do
                 begin
                  Image.Canvas.CopyRect(Rect(0,0,BmpWidth,i),
                                        OldBmp.Canvas,
                                        Rect(0,0,BmpWidth,i));
                  Image.Canvas.CopyRect(Rect(0,BmpHeight-i,BmpWidth,BmpHeight),
                                        OldBmp.Canvas,
                                        Rect(0,BmpHeight-i,BmpWidth,BmpHeight));
                  Image.Refresh;
                  Sleep(SleepTime);
                 end;
                end;
  horizontalShow :begin
                   Count:=BmpWidth div 2;
                   for i:=0 to Count do
                   begin
                    Image.Canvas.CopyRect(Rect(0,0,i,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(0,0,i,BmpHeight));
                    Image.Canvas.CopyRect(Rect(BmpWidth-i,0,BmpWidth,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(BmpWidth-i,0,BmpWidth,BmpHeight));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
 end;
 Image.Canvas.CopyRect(Rect(0,0,BmpWidth,BmpHeight),
                       OldBmp.Canvas,
                       Rect(0,0,BmpWidth,BmpHeight));
finally
 OldBmp.Free;
end;
end; 


                                

查看回复