gpt4 book ai didi

.net - XAML 性能 : Set alpha channel of a brush vs. FrameworkElement 的不透明度

转载 作者:行者123 更新时间:2023-12-04 14:50:21 25 4
gpt4 key购买 nike

对于需要半透明白色的给定 XAML 布局(在这种情况下提供类似玻璃的效果),哪种方法更适合设置透明度,为什么?:

  • 设置画笔的 Alpha channel 。例如。 #12FFFFFF
  • 设置 FrameworkElement 本身的不透明度,将画笔保留为 100% 白色。

  • 另外,WPF (4.0) 和 Silverlight 的答案不同吗?

    最佳答案

    直接来自 MSDN :

    Opacity on Brushes versus Opacity on Elements

    When you use a Brush to set the Fill or Stroke of an element, it is better to set the Brush.Opacity value rather than the setting the element's Opacity property. Modifying an element's Opacity property can cause WPF to create a temporary surface.



    但无论如何,请注意您仍在导致渲染管道做更多的工作。不透明度意味着它必须组合来自多个来源的像素才能得出最终的 RGB 值。因此,如果有可能完全去除透明度并用不透明的画笔模拟它,你应该这样做。听起来在您的情况下这可能是不可能的,但通常可以。

    关于.net - XAML 性能 : Set alpha channel of a brush vs. FrameworkElement 的不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7710908/

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