为什么在 Windows 中缩放 WPF 应用程序时会看到像素? [英] Why do I see pixels when zooming WPF application in Windows?

查看:25
本文介绍了为什么在 Windows 中缩放 WPF 应用程序时会看到像素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为使用 WPF 的随机应用程序开发了一个 GUI.我在应用程序窗口上放置了一堆开箱即用的 WPF 控件.我没有定制任何东西,没有使用位图等.

I have developed a GUI for a random application using WPF. I have a bunch of out of box WPF controls laid on the application window. I haven't customized anything, didn't use bitmaps, etc.

在 Windows 7 中运行我的应用程序并使用 Magnifier 应用程序进行缩放时(Win key + Plus key,放大的 GUI 显示像素.我可能错了,因为我无法解释,否则,但是 WPF 不应该提供 vector like 控件渲染吗?

When running my application and zooming using Magnifier application in Windows 7 (Win key + Plus key, the magnified GUI is showing pixels.I am probably wrong, because I can't explain it otherwise, but isn't WPF supposed to provide vector like control rendering?

感谢参与讨论.

  • Tim Sneath: Magnifier: An Interesting Discovery (archive)
  • WPF Vector based interface *(screenshot of WPF being vector scaled by Magnifier)
  • MSDN Blogs: Greg Schechter explains why it longer happens (archive)

推荐答案

回到 Vista 首次发布和 WPF 3.0 版本时,使用内置放大镜进行缩放实际上会进行基于矢量的缩放.

Back when Vista first shipped, and when WPF was on version 3.0, zooming with the built-in magnifier would actually do vector-based scaling.

当 WPF 3.5 Service Pack 1 发布时,这停止工作.(它在 sp1 之前的 3.5 中工作.)在那之前它工作的原因是 DWM(桌面窗口管理器) - Windows 的一部分负责呈现您在屏幕上看到的所有内容 - 使用 MILCORE.DLL 进行渲染.WPF 3.0 和 3.5 版也使用相同的组件来呈现 - 这意味着所有 WPF 内容都是本机内容,可以这么说.(实际上,在没有 DWM 的 Windows XP 上,MILCORE.DLL 是 WPF 出于自身利益而放在您的系统上的东西.但它内置于 Vista 和 Windows 7 中.)当 WPF 使用 MILCORE.DLL 时在 Vista 上渲染,由 DWM 应用的任何效果(如缩放)也将适用于您想要的 WPF 方式 - 它确实在没有像素化的情况下进行了缩放.

This stopped working when WPF 3.5 service pack 1 shipped. (It worked in 3.5 before sp1.) The reason it worked before then is that the DWM (Desktop Window Manager) - the part of Windows responsible for presenting everything you see on screen - uses MILCORE.DLL to do its rendering. Version 3.0 and 3.5 of WPF also used this same component to render - this meant that all WPF content was native content, so to speak. (In fact, on Windows XP, which doesn't have the DWM, MILCORE.DLL is something that WPF puts on your system for its own benefit. But it's built into Vista and Windows 7.) When WPF was using MILCORE.DLL to render on Vista, any effects applied by the DWM such as scaling would also apply in the way you want to WPF - it really did scale without pixelating.

不幸的是,情况不再如此.原因是 WPF 开始添加新的渲染功能.在 3.5 sp1 中,有问题的新功能是支持自定义像素着色器.为了实现这一点,微软必须发布 MIL 的更新.(媒体集成层——进行实际渲染的部分.)然而,他们并没有真正能够更新 MILCORE.DLL,因为那是 Windows 的一部分——这就是你在屏幕上看到的所有内容都在屏幕上的方式.发布新版本的 MILCORE.DLL 意味着将更新推送到 Windows.Windows 的发布计划与 .NET 的发布计划无关,因此 WPF 团队合理添加新功能的唯一方法是发布新的 MIL.(理论上他们可以通过 Windows 更新来完成,但由于 WPF 现在由 Microsoft 的不同部门拥有,而不是 Windows,这种事情在实践中似乎不会发生.)

Unfortunately, this is no longer the case. And the reason is that WPF started adding new rendering features. In 3.5 sp1, the new feature in question was support for custom pixel shaders. To enable that, Microsoft had to release an update to the MIL. (The Media Integration Layer - the bit that does the actual rendering.) However, they weren't really in a position to update MILCORE.DLL, because that's part of Windows - it's how everything you see on screen gets to be on screen. Releasing a new version of MILCORE.DLL effectively means pushing out an update to Windows. The release schedule for Windows is independent of that for .NET, and so the only way the WPF team could reasonably add new features was to ship a new MIL. (In theory they could have done it via Windows Update, but since WPF is now owned by a different division of Microsoft than Windows, that sort of thing doesn't seem to happen in practice.)

从 .NET 3.5 sp1 开始,MIL 位于名为 wpf_gfx_vXXXX.dll 的不同 DLL 中,其中 vXXXX 是版本号.在 .NET 4.0 中,它是 wpf_gfx_v0400.dll.

As of .NET 3.5 sp1, the MIL is in a different DLL called wpf_gfx_vXXXX.dll where vXXXX is the version number. In .NET 4.0, it's wpf_gfx_v0400.dll.

好处是 WPF 可以在每个新版本中添加新的渲染功能,而无需更新 Windows 本身.缺点是 WPF 的渲染不再像 Vista 发布时那样与 Windows 紧密集成.结果是,正如您所见,放大不再像以前那么有趣.

The upside is that WPF gets to add new rendering features with each new version, without needing Windows itself to be updated. The downside is that WPF's rendering is no longer as tightly integrated with Windows as it was briefly back when Vista shipped. And the upshot is, as you've seen, that magnifying is not as much fun as it used to be.

这篇关于为什么在 Windows 中缩放 WPF 应用程序时会看到像素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆