在离屏绘制时(例如 RenderTargetBitmap)可以得到 TextFormattingMode=Display 吗?
我正在 WPF 中绘制某些图像,这些图像将由游戏(由第三方开发)显示。我目前使用 RenderTargetBitmap 生成图像。不幸的是,这似乎只支持 Ideal
文本格式模式,导致小字体模糊。该应用程序是第三方游戏,因此无法使用图像。
我可以告诉 RenderTargetBitmap 假设它正在绘制用于当前监视器之一的图像吗?是否有其他方法让 WPF 使用 Display
渲染模式进行离屏绘制?
我理解为什么这在理论上似乎是错误的,但在实践中,我认为这并不是一件不合理的事情:
Display
模式允许的事情之一是别名文本,它在小尺寸下看起来比理想渲染更好,并且完全独立于伽玛等显示器属性。- 在 ClearType 中渲染的小
显示
模式文本的屏幕截图在任何屏幕上看起来都比理想
模式文本好得多,即使是那些具有不同伽玛值的屏幕。
WPF 渲染引擎可以做到这一点,还是我必须退回到 GDI? (使用 Aliased 或 ClearType 离屏渲染没有任何困难)
I'm drawing certain images in WPF which will be displayed by a game (developed by a third party). I currently produce the images using a RenderTargetBitmap
. Unfortunately it seems that this only supports the Ideal
text formatting mode, resulting in blurry small fonts. The application is a third-party game and thus there's no way around using images.
Can I tell the RenderTargetBitmap
to assume that it's drawing an image destined for one of the current montiors? Is there another way to get WPF to use the Display
rendering mode for off-screen drawing?
I understand why this might seem wrong in the theoretical sense, but in practice there are reasons why I think this is not an unreasonable thing to do:
- One of the things the
Display
mode allows is aliased text, which looks better at small sizes than theIdeal
rendering, and is completely independent of monitor properties such as gamma. - A screenshot of small
Display
-mode text rendered in ClearType looks far better on any screen, even those with different gamma, thanIdeal
-mode text.
Can the WPF rendering engine do this, or do I have to fall back onto GDI? (which has no difficulties with using Aliased or ClearType rendering off-screen)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然没有明显的方法可以做到这一点。我想绘制图像从来都不是 WPF 的目标;事实上,它在大多数时候都能很好地做到这一点,这一定是偶然的。
There is certainly no obvious way of doing this. I guess drawing to images was never a goal of WPF; the fact that it can actually do this fairly well most of the time must be accidental.
现在看来这行得通。其他人可以验证吗?以下是相关代码:
编辑:忘记提及我正在使用 .NET 4.5 框架
Edit2:显示和理想之间的差异在较小的字体大小下尤其明显。
It seems that this works now. Could someone else verify? Here's the relevant code:
Edit: Forgot to mention I'm using the .NET 4.5 framework
Edit2: The difference between Display and Ideal is especially noticeable at smaller font sizes.