透明度算法
方法一:首先,要能取得上层与下层颜色的 RGB三基色,然后用
r,g,b 为最后取得的颜色值;r1,g1,b1是上层的颜色值;r2,g2,b2是下层颜色值
r = r1/2 + r2/2;
g = g1/2 + g2/2;
b = b1/2 + b2/2;
以上为50%透明。若要使用不同的透明度用以下算法(ALPHA=透明度):
(50%以下)
r = r1 - r1/ALPHA + r2/ALPHA;
g = g1 - g1/ALPHA + g2/ALPHA;
b = b1 - b1/ALPHA + b2/ALPHA;
(50%以上)
r = r1/ALPHA + r2 - r2/ALPHA;
g = g1/ALPHA + g2 - g2/ALPHA;
b = b1/ALPHA + b2 - b2/ALPHA;
方法二:
TargetBmp[x,y].Red := (Bmp1[x,y].Red*alpha) + (Bmp2[x,y].Red*(1-alpha));
TargetBmp[x,y].Green := (Bmp1[x,y].Green*alpha) + (Bmp2[x,y].Green*(1-alpha));
TargetBmp[x,y].Blue := (Bmp1[x,y].Blue*alpha) + (Bmp2[x,y].Blue*(1-alpha));