图形特效 二

                             从中间向对边逐渐推拉显示图像
   输入参数:
     Image       要进行特效的TImage
     Direction   方向
     SleepTime   特效的快慢控制
}
procedure Img_CenterToDulBorderPush(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
  horizontalShow :begin
                   Count:=BmpWidth div 2;
                   for i:=0 to Count do
                   begin
                    Image.Canvas.CopyRect(Rect(Count-i,0,Count,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(0,0,i,BmpHeight));
                    Image.Canvas.CopyRect(Rect(Count,0,Count+i,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(BmpWidth-i,0,BmpWidth,BmpHeight));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
  verticalShow :begin
                 Count:=BmpHeight div 2;
                 for i:=0 to Count do
                 begin
                  Image.Canvas.CopyRect(Rect(0,Count-i,BmpWidth,Count),
                                        OldBmp.Canvas,
                                        Rect(0,0,BmpWidth,i));
                  Image.Canvas.CopyRect(Rect(0,Count,BmpWidth,Count+i),
                                        OldBmp.Canvas,
                                        Rect(0,BmpHeight-i,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;



{ 从对边向中间逐渐推拉显示图像
   输入参数:
     Image       要进行特效的TImage
     Direction   方向
     SleepTime   特效的快慢控制
}
procedure Img_DulBorderToCenterPush(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
  horizontalShow :begin
                   Count:=BmpWidth div 2;
                   for i:=0 to Count do
                   begin
                    Image.Canvas.CopyRect(Rect(0,0,i,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(Count-i,0,Count,BmpHeight));
                    Image.Canvas.CopyRect(Rect(BmpWidth-i,0,BmpWidth,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(Count,0,Count+i,BmpHeight));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
  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,Count-i,BmpWidth,Count));
                  Image.Canvas.CopyRect(Rect(0,BmpHeight-i,BmpWidth,BmpHeight),
                                        OldBmp.Canvas,
                                        Rect(0,Count,BmpWidth,Count+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
     CircleCount  圈数
     Direction    方向
     SleepTime    特效的快慢控制
}
procedure Img_SilVertexExpand(Image:TImage;CircleCount,Direction,SleepTime:Word);
var
OldBmp:TBItmap;
BmpWidth,BmpHeight:Integer;
i,AddX,AddY:Integer;
begin
OldBmp:=TBitmap.Create;
try
 OldBmp.Assign(Image.Picture.Graphic);
 Image.Picture:=nil;
 BmpWidth:=OldBmp.Width;
 BmpHeight:=OldBmp.Height;
 if CircleCount=0 then CircleCount:=1;
 AddX:=BmpWidth div CircleCount;
 AddY:=BmpHeight div CircleCount;
 if AddX=0 then AddX:=1;
 if AddY=0 then AddY:=1;
 case Direction of
  fromLeftTop :begin
                for i:=0 to CircleCount do
                begin
                 Image.Canvas.CopyRect(Rect(0,0,i*AddX,i*AddY),
                                       OldBmp.Canvas,
                                       Rect(0,0,i*AddX,i*AddY));
                 Image.Refresh;
                 Sleep(SleepTime);
                end;
               end;
  fromRightTop :begin
                 for i:=0 to CircleCount do
                 begin
                  Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,0,BmpWidth,i*AddY),
                                        OldBmp.Canvas,
                                        Rect(BmpWidth-i*AddX,0,BmpWidth,i*AddY));
                  Image.Refresh;
                  Sleep(SleepTime);
                 end;
                end;
  fromLeftBottom :begin
                   for i:=0 to CircleCount do
                   begin
                    Image.Canvas.CopyRect(Rect(0,BMpHeight-i*AddY,i*AddX,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(0,BMpHeight-i*AddY,i*AddX,BmpHeight));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
  fromRightBottom :begin
                    for i:=0 to CircleCount do
                    begin
                     Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,BmpHeight-i*AddY,
                                                BmpWidth,BmpHeight),
                                           OldBmp.Canvas,
                                           Rect(BmpWidth-i*AddX,BmpHeight-i*AddY,
                                                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;



{ 从单个顶点逐渐推拉显示图像效果
   输入参数:
     Image       要进行特效的TImage
     CircleCount 推拉的圈数
     Direction   方向
     SleepTime   特效的快慢控制
}
procedure Img_SilVertexPush(Image:TImage;CircleCount,Direction,SleepTime:Word);
var
OldBmp:TBItmap;
BmpWidth,BmpHeight:Integer;
i,AddX,AddY:Integer;
begin
OldBmp:=TBitmap.Create;
try
 OldBmp.Assign(Image.Picture.Graphic);
 Image.Picture:=nil;
 BmpWidth:=OldBmp.Width;
 BmpHeight:=OldBmp.Height;
 if CircleCount=0 then CircleCount:=1;
 AddX:=BmpWidth div CircleCount;
 AddY:=BmpHeight div CircleCount;
 if AddX=0 then AddX:=1;
 if AddY=0 then AddY:=1;
 case Direction of
  fromLeftTop :begin
                for i:=0 to CircleCount do
                begin
                 Image.Canvas.CopyRect(Rect(0,0,i*AddX,i*AddY),
                                       OldBmp.Canvas,
                                       Rect(BmpWidth-i*AddX,BmpHeight-i*AddY,
                                            BmpWidth,BmpHeight));
                 Image.Refresh;
                 Sleep(SleepTime);
                end;
               end;
  fromRightTop :begin
                 for i:=0 to CircleCount do
                 begin
                  Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,0,BmpWidth,i*AddY),
                                        OldBmp.Canvas,
                                        Rect(0,BmpHeight-i*AddY,i*AddX,BmpHeight));
                  Image.Refresh;
                  Sleep(SleepTime);
                 end;
                end;
  fromLeftBottom :begin
                   for i:=0 to CircleCount do
                   begin
                    Image.Canvas.CopyRect(Rect(0,BMpHeight-i*AddY,i*AddX,BmpHeight),
                                          OldBmp.Canvas,
                                          Rect(BmpWidth-i*AddX,0,BmpWidth,i*AddY));
                    Image.Refresh;
                    Sleep(SleepTime);
                   end;
                  end;
  fromRightBottom :begin
                    for i:=0 to CircleCount do
                    begin
                     Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,BmpHeight-i*AddY,
                                                BmpWidth,BmpHeight),
                                           OldBmp.Canvas,
                                           Rect(0,0,i*AddX,i*AddY));
                     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
     CircleCount 扩展的圈数
     SleepTime   特效的快慢控制
}
procedure Img_AllVertexToCenterExpand(Image:TImage;CircleCount,SleepTime:Word);
var
OldBmp:TBItmap;
i,BmpWidth,BmpHeight:Integer;
AddX,AddY:Integer;
begin
OldBmp:=TBitmap.Create;
try
 OldBmp.Assign(Image.Picture.Graphic);
 Image.Picture:=nil;
 BmpWidth:=OldBmp.Width;
 BmpHeight:=OldBmp.Height;
 if CircleCount=0 then CircleCount:=1;
 AddX:=BmpWidth div 2 div CircleCount;
 AddY:=BmpHeight div 2 div CircleCount;
 if AddX=0 then AddX:=1;
 if AddY=0 then AddY:=1;
 for i:=0 to CircleCount do
 begin
  Image.Canvas.CopyRect(Rect(0,0,i*AddX,i*AddY),
                       OldBmp.Canvas,
                       Rect(0,0,i*AddX,i*AddY));
  Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,0,BmpWidth,i*AddY),
                       OldBmp.Canvas,
                       Rect(BmpWidth-i*AddX,0,BmpWidth,i*AddY));
  Image.Canvas.CopyRect(Rect(0,BMpHeight-i*AddY,i*AddX,BmpHeight),
                       OldBmp.Canvas,
                       Rect(0,BMpHeight-i*AddY,i*AddX,BmpHeight));
  Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,BmpHeight-i*AddY,BmpWidth,BmpHeight),
                       OldBmp.Canvas,
                       Rect(BmpWidth-i*AddX,BmpHeight-i*AddY,BmpWidth,BmpHeight));
  Image.Refresh;
  Sleep(SleepTime);
 end;
 Image.Canvas.CopyRect(Rect(0,0,BmpWidth,BmpHeight),
                       OldBmp.Canvas,
                       Rect(0,0,BmpWidth,BmpHeight));
finally
 OldBmp.Free;
end;
end;


{ 从四个顶点逐渐向中心推拉显示图像效果
   输入参数:
     Image       要进行特效的TImage
     CircleCount 推拉的圈数
     SleepTime   特效的快慢控制
}
procedure Img_AllVertexToCenterPush(Image:TImage;CircleCount,SleepTime:Word);
var
OldBmp:TBItmap;
i,BmpWidth,BmpHeight:Integer;
AddX,AddY,CenterX,CenterY:Integer;
begin
OldBmp:=TBitmap.Create;
try
 OldBmp.Assign(Image.Picture.Graphic);
 Image.Picture:=nil;
 BmpWidth:=OldBmp.Width;
 BmpHeight:=OldBmp.Height;
 if CircleCount=0 then CircleCount:=1;
 AddX:=BmpWidth div 2 div CircleCount;
 AddY:=BmpHeight div 2 div CircleCount;
 CenterX:=BmpWidth div 2;
 CenterY:=BmpHeight div 2;
 if AddX=0 then AddX:=1;
 if AddY=0 then AddY:=1;
 for i:=0 to CircleCount do
 begin
  Image.Canvas.CopyRect(Rect(0,0,i*AddX,i*AddY),
                       OldBmp.Canvas,
                       Rect(CenterX-i*AddX,CenterY-i*AddY,CenterX,CenterY));
  Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,0,BmpWidth,i*AddY),
                       OldBmp.Canvas,
                       Rect(CenterX,CenterY-i*AddY,CenterX+i*AddX,CenterY));
  Image.Canvas.CopyRect(Rect(0,BMpHeight-i*AddY,i*AddX,BmpHeight),
                       OldBmp.Canvas,
                       Rect(CenterX-i*AddX,CenterY,CenterX,CenterY+i*AddY));
  Image.Canvas.CopyRect(Rect(BmpWidth-i*AddX,BmpHeight-i*AddY,BmpWidth,BmpHeight),
                       OldBmp.Canvas,
                       Rect(CenterX,CenterY,CenterX+i*AddX,CenterY+i*AddY));
  Image.Refresh;
  Sleep(SleepTime);
 end;
 Image.Canvas.CopyRect(Rect(0,0,BmpWidth,BmpHeight),
                       OldBmp.Canvas,
                       Rect(0,0,BmpWidth,BmpHeight));
finally
 OldBmp.Free;
end;
end; 



                                

查看回复