WPF 在缩放大型场景时的性能

发布于 2024-08-25 05:13:52 字数 766 浏览 5 评论 0原文

我有一个全屏应用程序,我希望能够放大某些区域。

我的代码工作正常,但我注意到,当我靠近时,放大动画(它对父级上的 ScaleTransform.ScaleX 和 ScaleTransform.ScaleY 属性进行动画处理) canvas)开始稍微下降,帧速率受到影响。

我没有使用任何位图效果或任何东西,理想情况下我希望我的场景变得比目前更复杂。

场景相当大,1980x1024,这是要求,无法更改。

当前的布局是这样的:

<Canvas x:name="LayoutRoot">
  <Canvas x:Name="ContainerCanvas">
    <local:MyControl x:Name="c1" />
    <!-- numerous or ther controls and elements that compose the scene  -->
  </Canvas>
</Canvas>

放大的代码只是对 ContainerCanvas 的 RenderTransform 进行动画处理,然后缩放其子项以提供所需的效果。

但是,我想知道是否需要将 ContainerCanvas 换成 ViewBox 或类似的东西?我以前从未在 WPF 中真正使用过 ViewBox/Viewport 控件,它们可以在这里帮助我吗?

平滑缩放是客户的一个巨大要求,我必须解决这个问题。

欢迎所有想法

非常感谢

马克

I have a full screen app that I want to be able to zoom in on certain areas.

I have the code working fine, but I notice that when I get closer in, the zoom in animation (which animates the ScaleTransform.ScaleX and ScaleTransform.ScaleY properties on a Parent canvas) starts to jerk down a little and the frame rate suffers.

Im not using any BitmapEffects or anything, and ideally I would like my scene to get more complicated than it currently already is.

The scene is quite large, 1980x1024, this is a requirement and cannot be changed.

The current layout is like this:

<Canvas x:name="LayoutRoot">
  <Canvas x:Name="ContainerCanvas">
    <local:MyControl x:Name="c1" />
    <!-- numerous or ther controls and elements that compose the scene  -->
  </Canvas>
</Canvas>

The code that zooms in just animates the RenderTransform of the ContainerCanvas, which in tern, scales its children which gives the desired effect.

However, Im wondering if I need to swap out the ContainerCanvas for a ViewBox or something like that? Ive never really worked with ViewBox/Viewport controls before in WPF can they even help me out here?

Smooth zooming is a huge requirement of the client and I must get this resolved.

All ideas are welcome

Thanks a lot

Mark

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

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

发布评论

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

评论(1

你在我安 2024-09-01 05:13:52

我发现双色调图像也存在类似的问题,需要进行缩放和平滑平移,但双色调图像需要抗锯齿才能使屏幕观看可接受。

显然,这种抗锯齿会导致性能问题。您是否使用过 RenderOptions.SetBitmapScalingMode() 来处理您正在显示的图像对象?
如果是这样,您可能必须在缩放动画的速度/性能和渲染图像的质量之间进行权衡。

我想到过但还没有时间实现的一种可能的解决方案是在动画期间切换到低质量位图缩放模式,并在动画结束时切换回高质量。

I see a similar problem with bitonal images which need to be zoomed and smooth panned, but being bitonal need to be anti-aliased to make onscreen viewing acceptable.

Obviously this anti-aliasing can cause performance issues. Have you played around with the RenderOptions.SetBitmapScalingMode() for the image object your are displaying?
If so you may have to trade off between the speed/performance of the zoom animation and the quality of the rendered image.

One possible solution I had thought of, but have not yet had time to implement, would be to switch into a low quality bitmap scaling mode during the animation, and switching back to high quality at the end of the animation.

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