How to increase productivity in comparison with GDI DrawImage (Unscaled)?

In my custom control handler, I repeat the set of predefined Bitmap objects and thus draw them into the client area:

C # Version:

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 Version:

 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 

The code works fine, but it gets scared when about a dozen objects are added to the collection. My question is: is there a way to speed this up? Can I use the Win32 bitblt function to replace DrawImageUnscaled? And if so, how?

Thanks!

Note. Googling for using BitBlt still gave me screen samples ...

+5
performance c # drawimage bitblt
source share
1 answer

Too late, but maybe someone else needs a solution.

I created a small GLGDI + library with similar GDI + syntax that runs on OpenTK: http://code.google.com/p/glgdiplus/

I am not sure of stability, it has some problems with DrawString (a problem with TextPrint from OpenTK). But if you need to improve the performance of your utility (for example, a level editor in my case), this may be the solution.

+6
source share

All Articles