posts - 36, comments - 30, trackbacks - 0, articles - 0

alpha photoshop

Posted on 2008-08-19 14:26 vcommon 阅读(153) 评论(0)  编辑 收藏 引用

The over operator is, in effect, the normal painting operation (see Painter's algorithm). The in operator is the alpha compositing equivalent of clipping.

As an example, the over operator can be accomplished by applying the following formula to each pixel value:

where Co is the result of the operation, Ca is the color of the pixel in element A, Cb is the color of the pixel in element B, and αa and αb are the alpha of the pixels in elements A and B respectively. If it is assumed that all color values are premultiplied by their alpha values (ci = αiCi), we can rewrite this as:


However, this operation may not be appropriate for all applications, since it is not associative ( i.e. it matters whether you first add object A and then object B or first B and then A. For example when building a picture from 3 color-channels it should not take effect in which order you add them, but with this non-associative version it would.). The associative version of this operation is very similar; simply take the newly computed color value and divide it by its new alpha value, as follows:

(转贴csdn zyl910(编程的乐趣在于编程控制硬件,与用图形学实现绚丽效果)

  R   =   R1   *   Alpha1   +   R2   *   Alpha2   *   (1-Alpha1)  
  G   =   G1   *   Alpha1   +   G2   *   Alpha2   *   (1-Alpha1)    
  B   =   B1   *   Alpha1   +   B2   *   Alpha2   *   (1-Alpha1)  
  Alpha   =   1   -   (1   -   Alpha1)   *   (   1   -   Alpha2)  
  R   =   R   /   Alpha  
  G   =   G   /   Alpha  
  B   =   B   /   Alpha  

7 楼gboy
使用   mmx   指令可以提高   alpha   混合的效率。