如何提高GDI的DrawImage(Unscaled)的性能?

在我的用户控件的绘制处理程序中,我遍历一组预定义的Bitmap对象,并将它们绘制到客户区:

C#版本:

private void Control_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; foreach (BitmapObj bmpObj in _bitmapObjCollection) { g.DrawImageUnscaled(bmpObj.Bitmap, bmpObj.Location); } } 

VB.NET版本:

 Private Sub Control_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint Dim g As Graphics = e.Graphics For Each bmpObj As BitmapObj In _bitmapObjCollection g.DrawImageUnscaled(bmpObj.Bitmap, bmpObj.Location) Next End Sub 

代码工作正常但是当十几个对象添加到集合时开始陷入困境。 我的问题是:有没有办法加快速度? 是否可以使用Win32 bitblt函数来替换DrawImageUnscaled? 如果是这样怎么样?

谢谢!

注意:到目前为止,谷歌搜索BitBlt的使用只产生了我的屏幕上限样本……

太晚了,但可能还有人需要解决方案。

我用类似的GDI +语法创建了小型库GLGDI +,它运行在OpenTK上: http : //code.google.com/p/glgdiplus/

我不确定稳定性,它在DrawString方面存在一些问题(来自OpenTK的TextPrint问题)。 但是,如果你需要为你的实用程序提升性能(比如我的情况下的级别编辑器),它可以是解决方案。

Interesting Posts