【发布时间】:2012-01-09 18:22:12
【问题描述】:
有很多关于渲染高质量图形的帖子,比如这个
High Quality Image Scaling Library
我需要使用 GDI+ 以大约 10fps 的帧速率在图形中渲染大约 6k+ 对象(直线和椭圆)。所以我的图形需要尽可能低质量的属性。
这是我所做的:
public static class GraphicsExtensions
{
public static void ToHighQuality(this Graphics graphics)
{
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
}
public static void ToLowQuality(this Graphics graphics)
{
graphics.InterpolationMode = InterpolationMode.Low;
graphics.CompositingQuality = CompositingQuality.HighSpeed;
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;
}
}
我是否忘记了什么,或者这是 Graphics 属性的最佳极值?
我在较低模式下以 5fps(202 毫秒/图像)进行绘图,在较高模式下以 3fps(330 毫秒/图像)进行绘图。
我不觉得有很大的不同,但我已经将我的性能问题减少到仅绘图......
一些数字:
- 1650 致电DrawLine
- 6600 致电FillEllipse
【问题讨论】:
-
为什么不用directx或wpf?
-
所有 2k 对象真的每帧都在移动吗?否则,对静态/移动对象使用单独的覆盖缓冲区。否则,请查看 Direct2D 绘图。
-
建议(可能不会更好):将线条、省略号和文本组合成
GraphicsPath对象。 -
好吧,如果我没有找到更好的 gdi+ 解决方案,我会记住你所有的想法!
-
一般情况下,NearestNeighbour 应该低于 low(除非它们相同)。 msdn.microsoft.com/en-us/library/… 的文档不多。
标签: c# .net graphics rendering gdi+