Calculate resulting RGB from 2 colors, one is transparent

后端 未结 1 1858
别那么骄傲
别那么骄傲 2020-12-30 11:12

I\'m looking for a formula to convert them.

I know to convert a general transparency it is

alpha * new + ( 1 - alpha ) * old

I have:



        
相关标签:
1条回答
  • It appears that your formula is precisely the formula used in your examples, calculated per component, and rounded up.

    R_c := ceiling(R_a * alpha) + ceiling (R_b * (1 - alpha))

    G_c := ceiling(G_a * alpha) + ceiling (G_b * (1 - alpha))
    B_c := ceiling(B_a * alpha) + ceiling (B_b * (1 - alpha))
    

    Strange, though, the R component doesn't appear to follow the rules. I'm inclined to wonder why.

    0 讨论(0)
提交回复
热议问题