本文介绍了在Windows窗体的文本渲染API最快?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要优化的文本呈现为一个C#在不规则显示大量小串格。在任何时候可以有超过5000个细胞中可见的每秒更新4次。字体系列和大小是整个细胞一致,虽然颜色可能与细胞间,变化也将粗体/斜体/平原。

We need to optimize the text rendering for a C# Windows Forms application displaying a large number of small strings in an irregular grid. At any time there can be well over 5000 cells visible that update 4 times per second. The font family and size is consistent across the cells, though the color may vary from cell to cell, as will bold/italic/plain.

我见过的相互矛盾的信息关于 TextRenderer.DrawText 网​​络与 Graphics.DrawString 是上最快/最好的,这就减少了一个 GDI 与水平比较。

I've seen conflicting information on the web about TextRenderer.DrawText vs. Graphics.DrawString being the fastest/best, which reduces to a GDI vs. GDI+ comparison at the Win32 level.

我也看到了在Windows XP与Windows Vista中完全不同的结果,但我的主要目标是Windows XP中。文章在并的是帮不上忙的位置: - )

I've also seen radically different results on Windows XP vs. Windows Vista, but my main target is Windows XP. Articles promising great advances under WinFX and DirectX 10 aren't helpful here :-)

这里有什么最好的方法?我不怕引入小的C ++ / CLI层和优化设备上下文处理,以挤压出更多的表现,但我想将采取哪个方向,一些明确的建议。

What's the best approach here? I'm not afraid of introducing a small C++/CLI layer and optimizing device context handling to squeeze out more performance, but I'd like some definitive advice about which direction to take.

编辑:
感谢最初的反应。我会努力的背景位图的渲染相结合,并与GDI等效调用坚持。

Thanks for the initial responses. I'll be trying a combination of background bitmap rendering and sticking with the GDI equivalent calls.

推荐答案

一个微软开发者发布了一个在他的博客文章它回答了原始速度的问题:他的系统,GDI DrawText的比GDI +的DrawString快约6倍。

A Microsoft developer has posted a GDI vs. GDI+ Text Rendering Performance article on his blog which answers the raw speed question: on his system, GDI DrawText was about 6 times faster than GDI+ DrawString.

如果你需要一个真正的速度妖,的TextOut更快比DrawText的,但你必须采取剪裁和自动换行照顾自己。 。ExtTextOut支持剪报

If you need to be a real speed demon, TextOut is faster than DrawText, but you'll have to take care of clipping and word-wrapping yourself. ExtTextOut supports clipping.

GDI渲染(TextRenderer)将与Windows使用GDI的其他部分更一致; GDI +试图rel=\"nofollow\">一些间距和加粗不一致是设备无关,因此

GDI rendering (TextRenderer) will be more consistent with other parts of Windows using GDI; GDI+ tries to be device-independent and so some spacing and emboldening are inconsistent. See the SQL Server 2005 Surface Area Configuration tool for an example of inconsistent rendering.

这篇关于在Windows窗体的文本渲染API最快?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!