如何尽可能高效绘制图形尽可能在WPF [英] How to draw graphics as efficiently as possible in WPF

查看:672
本文介绍了如何尽可能高效绘制图形尽可能在WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个工具,在很大程度上依赖于图的节点树。当前实现是用Java做的,我将它移植到C#的通用代码库,因此它可以通过各种渲染实现中使用,也因为我想利用WPF的强大的用户友好的界面。

I am creating a tool which relies heavily on graph-node trees. The current implementation is done in Java and I'm porting it to a generic code-base on C#, so it can be used by various rendering implementations and also because I want to use the power of WPF for a user-friendly interface.

浏览逛了一天后,我碰到的各种方法来绘制通过WPF的矢量图形。

After browsing around for a day, I came across various methods to draw Vector-graphics through WPF.

< A HREF =http://www.fernicola.org/loquitor/index.php?/archives/17-WPF-Pick-Your-API-Abstraction.html>这家伙讲WPF内对不同层次开发人员可以选择。正如我想用WPF纯粹是为了他的第一个渲染,我想在可视层的工作。

This guy speaks about different layers within WPF developers can choose from. As I want to use WPF PURELY for his rendering at first, I want to work on the "Visual Layer".

然后我遇到事情喜欢传来:
DrawingVisual
GeometryDrawing
FrameworkElement的 / 的UIElement /形状

I then came across things like: DrawingVisual, GeometryDrawing, FrameworkElement / UIElement / Shapes

所以,我有点被所有不同的实现,最终做同样的方式完全不同淹没。

So, I'm a bit overwhelmed by all the different implementations that do eventually the same in totally different ways.

该图的节点库已经被移植到C#已经与所有它的逻辑(包括碰撞检测,并拖动鼠标)。因为它是在头脑与图形的渲染制作(如XNA,SlimDX,OpenTK等),这将是在性能实现一个WPF渲染器(如,它会画什么图形库告诉它条款的最佳方式画?

The Graph-Node library has been ported to C# already with all it's logic (including collision detection and dragging with mouse). As it is made with graphic-renderers in mind (like XNA, SlimDX, OpenTK, etc.), what would be the best way in terms of performance to implement a WPF renderer (as in, it will draw whatever the graph library tells it to draw?

基本上,导致WPF控件作为画布,但它必须是超轻量级,而不是有除了提供我的方式来得出任何整齐的WPF功能我的圈子,线条等造型:)

Basically, the resulting WPF control acts as a canvas, but it has to be SUPER lightweight and not have any neat WPF features besides providing me a way to draw my circles, lines and other shapes :)

编辑:

我基本上想知道:什么是路要走?我是否延长帆布为主机为我的图形,然后加我UIElement的自定义实现?或者,我可以有一个类可以借鉴一切(如在一百万超超图)。就像在GDI或Java的喷漆方法(它给出了一个Graphics对象做的一切)压倒一切的OnPaint。

I basically want to know: What is the way to go? Do I extend Canvas as "Host" for my graphics and then add my custom implementation of a UIElement? Or can I have one class which can draw EVERYTHING (as in, one mega super ultra graphic). Much like overriding OnPaint in GDI or Paint-method in Java (which gives a Graphics object to do everything with).

推荐答案

我倒是推荐阅读优化性能:2D图形和图像(死链接 - 读通过互联网档案) -

I'd recommend reading Optimizing Performance: 2D Graphics and Imaging (dead link -- readable via Internet Archive) -

基本上,的物体会比图形一般。这可能是你想要使用什么样的。

Basically, Drawing objects will be lighter weight than Shapes, in general. This is probably what you want to use.

这篇关于如何尽可能高效绘制图形尽可能在WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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