GDI+ 1.0 vs GDI+ 1.1

wyrd

Well-known member
Joined
Aug 23, 2002
Messages
1,408
Location
California
Does anyone know if GDI+ in .NET framework version 1.1 has any performance increases over the 1.0 version?

Im only getting 28 fps when drawing 300 to 336 32x32 images on the screen. I need it to go faster. No, using DirectDraw is not an option! :D Neither is the Windows API. :P
 
One thing that I found makes drawing the images faster is using your own double bufffering instead of default. And (I didnt try this) you could handle the WndProc directly and that should probably be the fastest.
 
From numerous threads, Ive read that its recommonded you use a forms SetStyles, and do all of your drawing inside the Paint event. This is contradictory to your suggestion about using my own double buffering.

Did I misunderstand something?
 
Actually on second examination, I found that I used the windows api to do this but I manually double buffed instead of automatic and it was much faster that way. What I mean is that I used SetStyle to double buff, drew with the api and then tried double buffing manually and found that manual double buffing is much faster.

But forget that, you said you did not want to use the windows api. PentiumGuy, it would be better to put startup objects in the Forms constructor instead of in Load() I think. For some things, however, Load() is the only startup method that will work right. But for most that is what the Constructor is designed to do (Where InitializeComponent is).

Have you used DrawImageUnscaled instead of DrawImage?
Another thing you can do is override the OnPaintBackground event and do nothing there. But you probably dont want to do that.

I have really exhaused all options in using GDI+ for drawing images. I dont think it gets any better. Maybe try lowering the Bpp of the images after they are declared.
 
Last edited by a moderator:
Ah.. yeah Windows API is faster then GDI+. Hopefully theyll speed up GDI+ in future releases so itll be closer in performance to the Windows API drawing functions.

DrawImageUnscaled looks interesting. Im drawing images using TextureBrush though (its faster then DrawImage), but Ill give DrawImageUnscaled a shot.. just for the heck of it.
 
I doubt theyll ever catch up to the raw speed of API, but the extreme ease and flexibility of GDI+ makes it worth the small performance hit (in many cases). If you are really serious about speed, DX9 is the best route.
 
With the games Im making, speed isnt to much of an issue (so long as I can keep it around 25 FPS its all good). I can solve the current problem by using a smaller display area to draw a smaller map (less tiles). I suppose at some point Ill need to get down and dirty with DirectDraw and then eventually DirectX.
 
Originally posted by wyrd
Well yes, but DD is 2d, while DX forces you to use 3d. I consider them different. :)

DirectX doesnt force you to use 3D. You can use DirectDraw for 2D, Direct3D for 3D and APIs like DirectSound for sound or DirectInput for input. All of those are based on DX and are part of, not only 3D :).
:)
 
Yeah it does, becuase you have to pass in an object of Image type to the brush, so you can pass in Bitmap object which you made transparent using MakeTransparent.
 
Its not. Ive tested. The API is much faster (for simple operations at least). I drew 2000 pictures on the form with GDI+ and it took like 500ms, and the same with GDI32 took about 200ms. However, in a real game situation with texturebrushes, solidbrushes, bitmaps, text, and the whole bit being rapidly drawn on the screen, its possible the speed gap would get smaller or disappear. Im not totally sure how GDI32 scales to meet larger tasks.

However, the capabilities of GDI+ and the GDI+ objects in general (even just the fact that there are real GDI+ objects) made it totally worth it for most situations.
 
DirectX doesnt force you to use 3D. You can use DirectDraw for 2D, Direct3D for 3D and APIs like DirectSound for sound or DirectInput for input. All of those are based on DX and are part of, not only 3D :).
:)

Alright.. you got me there. :P I always seem to intermix DirectX w/ Direct3D. Perhaps I should stop doing that.

Yeah it does, becuase you have to pass in an object of Image type to the brush, so you can pass in Bitmap object which you made transparent using MakeTransparent.

As far as I know TextureBrush doesnt support transparency (which is why it draws faster then DrawImage). But since Ive been wrong about everything else.. I just dont know anymore. :P
 
It does, before passing in the Bitmap object to the TextureBrush use this:
Code:
BitmapObject.MakeTransparent(Color to make transparent)
:)
 
Just to clarify:

DirectX is a package of other smaller libraries, such as DirectDraw, DirectSound, DirectMusic, DirectInput, and Direct3D. When you use any of those, you are using DirectX.
 
Back
Top