首页  编辑  

两个图片之间的淡入淡出

Tags: /超级猛料/Picture.图形图像编程/控件和绘图/   Date Created:

只能将两副画分成16部进行淡出

DHd为目标图的handle,SHd为源图的handle,其他为坐标

procedure  Fade(DHd,x,y,width,height,SHd,Sx,Sy:integer);

type ByteArray=array[0..0] of Byte;

    SIntArray=Array[0..0] of SmallInt;

var Count,i,step : Integer;

   DImg  : TBitmap;

   PDbit,PSbit : ^byteArray;

   PDif : ^SIntArray;

begin

DImg:=TBitmap.Create;

Count:=Height*Width*3;

DImg.PixelFormat:=pf24bit;

DIMg.Width:=Width;

DImg.Height:=Height;

GetMem(PSbit,Count);

GetMem(PDbit,Count);

GetMem(PDif,Count*2);

BitBlt(DImg.Canvas.Handle,0,0,Width,Height,DHD,x,y,SRCCOPY);

Getbitmapbits(DImg.Handle,Count,PDBit);

BitBlt(DImg.Canvas.Handle,0,0,Width,Height,SHD,Sx,Sy,SRCCOPY);

Getbitmapbits(DImg.Handle,Count,PSBit);

For i:=0 to Count-1 do

   PDif^[i]:=(PSbit^[i]-PDbit^[i]);

for Step:=1 to 15 do

  begin

  For i:=0 to Count-1 do

     PSbit^[i]:=PDbit^[i]+(Pdif^[i]*Step) shr 4;

  SetBitmapBits(DImg.handle,Count,PSbit);

  BitBlt(DHD,x,y,Width,Height,DImg.Canvas.Handle,0,0,SRCCOPY);

  sleep(100);

  End;

BitBlt(DHD,x,y,Width,Height,SHD,SX,SY,SRCCOPY);

FreeMem(PDif,Count*2);

FreeMem(PSBit,Count);

FreeMem(PDBit,Count);

DImg.Free;

end;