WPF 应用程序的帧速率限制?

发布于 2024-07-07 22:15:02 字数 100 浏览 8 评论 0原文

我想知道是否有办法限制进程内的 WPF 帧速率? 即我不想限制单个动画的帧速率,但全局 我的整个应用程序的帧率。

我想我以前见过类似的东西,但现在找不到了。

I wonder if there is a way to limit the WPF framerate within a process?
i.e. I do not want to limit a single animation's framerate, but the global
framerate for my whole application.

I think I've seen something like this before but I can't find it anymore.

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

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

发布评论

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

评论(1

紧拥背影 2024-07-14 22:15:02

如何控制 WPF 动画的帧速率

动画非常酷,但它们可能会导致 CPU 负载过高。 一
原因可能是由于旧显卡导致缺少硬件加速
适配器或软件渲染约束。 另一个原因可能是
动画的高帧速率设置为 60 fps
默认。

您可以通过覆盖轻松降低所有动画的帧速率
时间线的 DesiredFrameRate 属性。 只需添加以下内容
为您的项目编写代码并尝试设置以找到合适的
性能和美观之间的权衡。

Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline),   
  新的 FrameworkPropertyMetadata { 默认值 = 30 }); 
  

或者您可以使用以下代码在 XAML 中单独设置每个动画的帧速率:

持续时间="0:0:0.5"  
                   从=“1.0”到=“0.5”Timeline.DesiredFrameRate=“30”/> 
  

Source

https://www .wpftutorial.net/FrameRate.html

How to control the frame rate for WPF animations

Animations are very cool, but they can cause a high CPU load. One
reason could be a missing hardware acceleration due to a old graphics
adapter or a software rendering constraint. Another reason could be
the the high frame rate of animations that is set to 60 fps by
default.

You can easily lower the framerate for all animations by overriding
the DesiredFrameRate property of the timeline. Just add the following
code to your project and play around with the setting to find a good
tradeoff between performance and aesthetic.

Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline),  
new FrameworkPropertyMetadata { DefaultValue = 30 });

Or you can set the framerate individually for each animation in XAML, using the following code:

Duration="0:0:0.5" 
                 From="1.0" To="0.5" Timeline.DesiredFrameRate="30" />

Source

https://www.wpftutorial.net/FrameRate.html

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