问题描述
在数字成像中,当覆盖两个可视层时,有多种方法可以计算出当来自下层的光以某种方式穿过障碍层时产生的图像。这样可以提供自然现象不会出现的效果,例如增加颜色。
以下是Photoshop中提供的图层混合模式菜单的示例:
I recommend visiting the article Understanding Blending Modes if this topic isn't something you're familiar with. It provides a great showcase of the results of each option against two layers.
As far as I can tell, WPF only provides the 'Normal' option. That is, the following UI just blends colours as though they were coloured gels:
<Grid>
<Ellipse Width="40" Height="40" Fill="#80FF0000" Margin="16,0,0,0" />
<Ellipse Width="40" Height="40" Fill="#8000FF00" Margin="32,32,0,0" />
<Ellipse Width="40" Height="40" Fill="#800000FF" Margin="0,32,0,0" />
</Grid>
Which looks like this:
I'd like to know if there's any way to control the way in which layers blend.
What you are looking for is called blend modes if you google it you'll find a lot.Here is a simple example how it can be achieved using pixel shaders. You would use multi-input shader effect for this.
Here is a very good complete tutorial that walks you through creating a reusable library of blend modes using multi-input shader effect.
Blend modes as an intrinsic part of the WPF APIs has been frequently requested since early CTPs but never made it into the product.
这篇关于WPF-控制半透明层之间的混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!