public static int[] ColorAlpha(int frontA, int frontR, int frontG, int frontB, int backA, int backR, int backG, int backB)
{
int r = frontR * frontA / 255 + backR * backA / 255 * (1 - frontA / 255);
int g = frontG * frontA / 255 + backG * backA / 255 * (1 - frontA / 255);
int b = frontB * frontA / 255 + backB * backA / 255 * (1 - frontA / 255);
int a = 1 - (1 - frontA / 255) * (1 - backA / 255);
return new int[] { a, r, g, b};
}
算法:
前景颜色值: R1,G1,B1,A1
背景颜色值: R2,G2,B2,A2
则混合后颜色值:
R = R1 * A1 + R2 * A2 * (1-A1)
G = G1 * A1 + G2 * A2 * (1-A1)
B = B1 * A1 + B2 * A2 * (1-A1)
A = 1 - (1 - A1) * (1 - A2) ;
标签:A1,C#,混合,frontA,int,A2,Alpha,backA,255 From: https://www.cnblogs.com/RedSky/p/18340619