2017-05-26 72 views
0

我正在处理一些Win2D效果,我很难找到一种合适的方法使我的UI内容足够黑暗,以便它上面的文本很容易阅读。仅当Win2D的效果不够时才会使内容变暗?

现在这是我的代码的一部分:

ArithmeticCompositeEffect composite = new ArithmeticCompositeEffect 
{ 
    MultiplyAmount = 0, 
    Source1Amount = 0.2f, 
    Source2Amount = 0.8f, 
    // The Source1 parameter will be assigned later on with the EffectFactory 
    Source1 = new CompositionEffectSourceParameter(nameof(myBackground)), 
    Source2 = new ColorSourceEffect { Color = Colors.Black } 
}; 

所以我混我用一个统一的黑色内容(源1),这将有效地使整个事情更暗。我虽然一个问题:

  • 这使得暗内容太暗,轻内容不够

我听说,这是可以使用BlendEffect设置为BlendEffectMode.Exclusion的模式是暗解决这个问题,但我不知道如何正确设置。我尝试过使用此效果将我的第一个效果与统一的黑色结合起来,但结果中没有任何变化。

所以我的问题是:

其中Win2D效果(不一定排除混合,如果我们在这里不会是正确的选择),我可以申请,以确保我的内容总是比规定的阈暗(如此足够黑暗),而不会使内容几乎变黑?

感谢您的帮助!

回答

0

我发现使用Win2D效果可以解决这个问题,并且将结果图叠加在原始效果上(可能需要一定的强度以使原始图像根据情况或多或少变暗)。

一个例子是:

LuminanceToAlphaEffect alphaEffect = new LuminanceToAlphaEffect 
{ 
    Source = new CompositionEffectSourceParameter(nameof(myBackground)) 
}; 
ArithmeticCompositeEffect composite = new ArithmeticCompositeEffect 
{ 
    MultiplyAmount = 0, 
    Source1Amount = 1 - intensity, // Intensity is in the [0..1] range 
    Source2Amount = intensity, 
    // The Source1 parameter will be assigned later on with the EffectFactory 
    Source1 = new CompositionEffectSourceParameter(nameof(myBackground)), 
    Source2 = alphaEffect  
}; 
相关问题