什么是最好的方法,以呈现图表,然后保存在硬盘上,以便进一步分发使用WPF?通过使用以下类型,我找到了许多实现这一目标的方法:
当然,我将编写一个应用程序来测试每个程序的速度。但有谁能告诉我:
我是否在正确的轨道上? rendering?
,其中之一是performance?最好的
发布于 2010-08-09 09:26:07
这完全取决于您的实际使用情况,在您的例子中,您提到了在硬盘上保存以“进一步分发”--我将假设您将它们保存为映像(jpg或png),而不是作为wpf对象(xaml)。
- The fastest way to draw in WPF is to inherit from FrameworkElement (not Adorner) and override OnRender.
- When the data changes often it is recommended to use multiple DrawingVisual objects because then you don't have to re-render everything when one value change - but this is not relevant for you since the image won't change after you save it anyway.
- WritableBitmap is used for raw bitmap access, you use it when you decide to give up on all the nice layout and drawing WPF gives you because you can't take the overhead, if this is the case you should re-read my first point above.
因此,总而言之,您提出的问题是错误的:-)如果您需要将图像保存到磁盘上,而不是WPF呈现速度成为瓶颈,或者您不应该首先使用WPF。如果您确实使用了WPF,只需选择最简单的代码即可。
顺便说一句:Adorner用于在普通UI之上显示“浮动”元素,您可以将它们用于类似工具提示的特性,但不用于主图表呈现(而且您可能根本不想要它们,因为您的主要用途是将图像保存到磁盘),FrameworkElement是您要寻找的基类。
https://stackoverflow.com/questions/3438407
复制相似问题