在我的用户控件的绘制处理程序中,我迭代了一组预定义的 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 的使用只产生了我的屏幕截图样本......