为什么在 Windows 中缩放 WPF 应用程序时会看到像素?
我使用 WPF 为随机应用程序开发了一个 GUI。我在应用程序窗口上放置了一堆开箱即用的 WPF 控件。我没有自定义任何内容,没有使用位图等。
在 Windows 7 中运行我的应用程序并使用放大镜应用程序进行缩放时(Win 键 + 加号键
,放大的 GUI 显示像素。我是 ,因为我无法以其他方式解释它,但是 WPF 不应该提供类似的控件渲染吗?
您参与讨论。
可能是错的
- 感谢 ://blogs.msdn.microsoft.com/tims/2006/04/04/magnifier-an-interesting-discovery/" rel="nofollow noreferrer">放大镜:一个有趣的发现 (存档)
- 基于 WPF Vector 的界面 *(屏幕截图WPF 由放大镜进行矢量缩放)
- MSDN 博客:Greg Schechter 解释了为什么这种情况不再发生 (存档)
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.
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?
Thanks for participating in the discussion.
Bonus Reading
- 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
早在 Vista 首次发布时,当 WPF 处于 3.0 版本时,使用内置放大镜进行缩放实际上会进行基于矢量的缩放。
当 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 方式应用 - 它确实在没有像素化的情况下进行了缩放。
不幸的是,现在情况已不再如此。原因是 WPF 开始添加新的渲染功能。在 3.5 sp1 中,有问题的新功能是支持自定义像素着色器。为了实现这一点,微软必须发布 MIL 更新。 (媒体集成层 - 进行实际渲染的部分。)但是,他们实际上无法更新 MILCORE.DLL,因为那是 Windows 的一部分 - 这是您在屏幕上看到的所有内容如何显示在屏幕上的方式。发布新版本的 MILCORE.DLL 实际上意味着推出 Windows 更新。 Windows 的发布计划与 .NET 的发布计划无关,因此 WPF 团队合理添加新功能的唯一方法是发布新的 MIL。 (理论上,他们可以通过 Windows 更新来完成此操作,但由于 WPF 现在由 Microsoft 的不同部门拥有,而不是 Windows,因此这种情况在实践中似乎不会发生。)
从 .NET 3.5 sp1 开始,MIL位于名为 wpf_gfx_vXXXX.dll 的不同 DLL 中,其中 vXXXX 是版本号。在 .NET 4.0 中,它是 wpf_gfx_v0400.dll。
好处是 WPF 可以在每个新版本中添加新的渲染功能,而不需要更新 Windows 本身。缺点是 WPF 的渲染不再像 Vista 发布时那样与 Windows 紧密集成。结果,正如您所看到的,放大不再像以前那么有趣了。
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.
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.
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.)
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.
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.
放大镜应用程序实现了自己的缩放图像渲染,因此这就是您看到像素的原因。 WPF 确实使用矢量图形,但在这种情况下,渲染缩放图像的不是 WPF 应用程序本身。
如果您使用 Snoop 之类的东西,您可以看到缩放后的 WPF 矢量图形渲染正在运行。
The magnifier application implements its own zoomed image rendering, so that's why you are seeing pixels. WPF does use vector graphics, but in this situation it's not the WPF application itself that is rendering the zoomed image.
If you use something like Snoop you can see zoomed and scaled WPF vector graphics rendering in action.
我想,Windows 7 放大镜会拍摄实际应用程序屏幕 UI 的快照,然后将其本身放大(这不是 WPF 应用程序的特例)。当然,它可以访问的只是像素,而不是在场景后面工作的矢量图形。
I suppose, Windows 7 magnifier takes a snapshot of actual application on-screen UI, and then magnifies it itself (not making a special case for WPF applications). Of course what it can access is just the pixels, not the vector graphics which works behind the scene.
Windows-7 放大镜是基于像素的,但放大镜模式有所不同,具体取决于航空主题是否处于活动状态。
仅在使用 Areo 主题时,其他视图(“停靠”除外)才可选。
The Windows-7-Magnifier is pixel based, but there is a difference in magnifier mode depending on wether an Aero-theme is active or not.
Only with Areo theme other Views (except "Docked") are selectable.