图片叠加算法解决办法
图片叠加算法
将前景色与背景图片叠加, 现在的这种方法速度感觉太慢了
不知道还有没有其它比较高效的算法做到上面的功能
------解决方案--------------------
可找maozefa
------解决方案--------------------
AlphaBlend
------解决方案--------------------
Trunc((B1*(255-Alphal)+B2*Alphal)/255);
不建议这么写
用移位操作
((B1*(255-Alphal)+B2*Alphal) shr 8);
procedure TCopyScreent.AlphalBmp(BackBmp, foreBmp: TBitmap; Alphal: Byte ; Rect : TRect);
var R1 , G1 , B1 , R2 , G2 , B2 : Byte;
X , Y : Integer;
PB , PF : PByteArray;
begin
BackBmp.PixelFormat := pf24bit;
foreBmp.PixelFormat := pf24bit;
for Y := 0 to BackBmp.Height-1 do
begin
PB := BackBmp.ScanLine[Y];
PF := foreBmp.ScanLine[Y] ;
X:=0;
while X<=(BackBmp.Width-1)*3 do
begin
Inc(X,3) ;
if (X>=Rect.Left*3) and (X<=Rect.Right*3) and (Y>=Rect.Top) and (Y<=Rect.Bottom) then
begin
Continue;
end
else
begin
B1 := PB[X]; G1 := PB[X+1]; R1 := PB[X+2];
B2 := PF[X]; G2 := PF[X+1]; R2 := PF[X+2];
PB[X] := Trunc((B1*(255-Alphal)+B2*Alphal)/255);
PB[X+1] := Trunc((G1*(255-Alphal)+G2*Alphal)/255);
PB[X+2] := Trunc((R1*(255-Alphal)+R2*Alphal)/255);
end;
end;
end;
end;
将前景色与背景图片叠加, 现在的这种方法速度感觉太慢了
不知道还有没有其它比较高效的算法做到上面的功能
------解决方案--------------------
可找maozefa
------解决方案--------------------
AlphaBlend
------解决方案--------------------
Trunc((B1*(255-Alphal)+B2*Alphal)/255);
不建议这么写
用移位操作
((B1*(255-Alphal)+B2*Alphal) shr 8);