在原图上在加一张小图,半透明
procedure BlendBmp(BkGround,FrGround: TBitmap;Left,Top,Alpha,TransR,TransG,TransB: Integer);
var
X,Y: Integer;
PB,PF: PbyteArray;
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];
if(B2=TransB) and (G2 = TransG) and (R2 = TransR) then
Continue;
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;