gpt4 book ai didi

WPF DropShadowEffect - 意外的色差

转载 作者:行者123 更新时间:2023-12-02 00:06:31 25 4
gpt4 key购买 nike

我有一个带有 DropShadowEffect 的 TextBlock。某些阴影颜色显示的颜色比指定的颜色更暗,就好像它们是有色的一样。但是,并非每种颜色都会发生这种情况。有谁知道原因或纠正方法?

这是一个非常基本的例子:

<StackPanel>
<StackPanel.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontSize" Value="100" />
<Setter Property="Text" Value="THIS IS TEXT WITH A SHADOW" />
</Style>
</StackPanel.Resources>

<!-- Expected Result -->
<TextBlock Foreground="#FFFF0000">
<TextBlock.Effect>
<DropShadowEffect ShadowDepth="20" Color="#FFFF0000" />
</TextBlock.Effect>
</TextBlock>

<!-- Unexpected Result -->
<TextBlock Foreground="#FF005E20">
<TextBlock.Effect>
<DropShadowEffect ShadowDepth="20" Color="#FF005E20" />
</TextBlock.Effect>
</TextBlock>

</StackPanel>

也许它与原色有关??

最佳答案

它在某处将 DropShadowEffect 转换为特定的 Sc 值。

越接近 1,差异越小(因此 FF/255/1 工作得很好)

通过调查和研究 ScRGB,ScRGB 的 Gamma 值约为 2.2。因此,当从 RGB 转换为 ScRGB 时,您可能需要除以 255,然后对值的 n 次 (2.2) 根进行除以得出最终值。

例如

value 5E is 94

94 / 255 = 0.36862745098039215686274509803922

2.2root of 94/255 = 0.635322735100355

0.635322735100355 * 255 = A2

因此当设置前景的ScG为5E时,需要将DropShadowEffect设置为A2。

这只是我的观察,也是我从研究中得出的结论。

MS 为什么要这样实现?我不知道

来源:

关于WPF DropShadowEffect - 意外的色差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18130968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com