DropShadowBitmapEffect 在 TextBlock 上不起作用

发布于 2024-07-05 08:59:08 字数 441 浏览 5 评论 0原文

有谁知道为什么 DropShadowBitmapEffect 和 EmbossBitmapEffect 不能在 WPF 中的 TextBlock(而不是 textBOX)上工作? OuterGlow、Blur 和 Bevel 似乎工作得很好。


透明背景画笔显然不是答案,因为您可以使用空背景画笔获得阴影。 投影的默认柔和度为 50%,如果字体较小,则柔和度会过多地消散阴影。 柔软度在 39% 左右似乎急剧下降(此时阴影或多或少消失)。 尝试将其设置为 0 并慢慢向上移动,直到找到仍然显示阴影的数字。


另请注意:柔软度绝对是一个因素,但请注意,在 Xaml 中,有效值实际上只有 0 到 1,但在 Blend 中,它显示为最高 100 的百分比。因此,如果您在 Xaml 中将值设置为 100,它将被完全消散。


背景画笔=透明解决方案仍然可以用于浮雕效果

Does anyone know why the DropShadowBitmapEffect and the EmbossBitmapEffect won't work on a TextBlock (not textBOX) in WPF? OuterGlow, Blur and Bevel seem to work fine.


The transparent background brush is apparently not the answer because you can get a dropshadow with a null background brush. The default softness on a dropshadow is 50% and if you have a small font, the softness dissipates the shadow too much. There seems to be a steep drop off around softness of 39% (at which point the shadow more or less disappears). Try setting it to 0 and slowly moving you're way up until you find a number that still shows the shadow.


Yet another note: the softness is definitely a factor, but be aware in Xaml the valid values are really only 0 to 1, but in Blend it shows it as a percentage up to 100. So if you set the value to 100 in Xaml, it will be completely dissipated.


The background brush = transparent solution still may work for the embossing effect

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南烟 2024-07-12 08:59:08

重要旁注:您不应该再使用 BitmapEffects。 使用基于.net 3.5 SP1中引入的ShaderModel效果的Effect属性,它使用硬件渲染并且具有更好的性能。

更多信息

Important Sidenote: you shouldn't really be using BitmapEffects any more. Use the Effect property based on ShaderModel effects introduced in .net 3.5 SP1, it uses hardware rendering and has far better performance.

More Information

难如初 2024-07-12 08:59:08

位图效果通过查看后渲染像素并对它们运行标准图像处理来工作。 它应该仅取决于像素的颜色。 我想知道他们的算法是否在白色上效果不佳。 尝试更改颜色以查看是否有效果 - 如果有效果,您可能需要尝试在下面放置一个黑色面板,并在其上设置阴影。

编辑:提问者找到了答案

“感谢您为我指明了正确的大方向。重要的不是文本的颜色或 DropShadow,需要的是使 TextBlock 上的背景画笔成为透明画笔(Alpha = 0) 而不是空。”

Bitmap effects work by looking at the post-rendered pixels and running standard image manipulation on them. It should only be dependent on the color of the pixels. I wonder if their algorithms don't work well on white. Try changing the color to see if that has an effect -- if it does, you might want to try putting a black panel underneath with drop shadow set on it.

Edit: The questioner found the answer

"Thanks for pointing me in the correct general direction. It wasn't the color of the text or the DropShadow that mattered, what is needed is to make the Background Brush on the TextBlock the Transparent Brush (Alpha = 0) instead of null."

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文