摘要 |
A multi-layered image may be rasterized onto a background by considering each layer in the image from front to back. The alpha channel of a background buffer is cleared, so that it may act as an accumulator of total consumed opacity. Each image layer, from front to back, is then considered. For each layer, the layer's alpha value is multiplied by the complement of the alpha channel's current value, and the product is added to the background alpha channel. The background alpha channel is then multiplied by a global alpha value. The background color values are then pre-darkened by the complement of the resulting background alpha channel value. The background alpha channel is then cleared again, and the layers are rasterized and added, from front to back, onto the pre-darkened background, this time taking into consideration the per-layer color values. |