BkGround 背景
FrGround 前景 left,top 前景混合左上角位置
Alpha 0..255
Procedure BlendBmp(BkGround,FrGround:TBitmap;Left,Top,Alpha:Integer);
Var X,Y:Integer;
PB,PF
byteArray;
R1,R2,G1,G2,B1,B2:Integer;
Begin
BkGround.PixelFormat:=pf24bit;
FrGround.PixelFormat:=pf24bit;
For Y:=Top to BkGround.Height-1 do
Begin
IF Y-Top>FrGround.Height-1 then Break;
PB:=BkGround.ScanLine[Y];
PF:=FrGround.ScanLine[Y-Top];
For X:=Left to BkGround.Width-1 do
Begin
IF X-Left>FrGround.Width-1 then Continue;
B1:=PB[X*3]; G1:=PB[X*3+1]; R1:=PB[X*3+2];
B2:=PF[(X-left)*3]; G2:=PF[(X-left)*3+1]; R2:=PF[(X-left)*3+2];
PB[X*3]:=(B2*Alpha+B1*(255-Alpha)) div 255;
PB[X*3+1]:=(G2*Alpha+G1*(255-Alpha)) div 255;
PB[X*3+2]:=(R2*Alpha+R1*(255-Alpha)) div 255;
End;
End;
End;