Hu Flung Dung
Mar 9th, 2003, 10:05 PM
Alright, I've seen many examples from people all over the net trying to mimic double buffering by using Image/bitmap and graphics objects! However, all of those examples are VERY slow and inefficient!!!!!
Here's the absolute BEST way to do double buffering with the GDI+:
First, add the following 3 lines into your form's constructor (the New method, where it says "put initialization code here"):
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.DoubleBuffer, True)
SetStyle(ControlStyles.UserPaint, True)
Now, draw all of your graphics in the Paint event. They will appear only after the Paint event terminates!
Finally, as I said, Image and Bitmap objects are slow. Their good for image manipulation, but definately NOT for speed. You'll be very lucky to render them at about 10 FPS (even with a fast computer), and it will take up all of your processing power and much of your RAM. If you need extra speed and more efficient use of system resources, create TextureBrush objects from your Image/Bitmap objects, and use those in your loops in place of the image and bitmap objects, or wherever you need the speed.
I havn't seen either of these tricks documented very well, and I've seen too many people make futile attempts to mimic them. I hope this helps you all out!
Here's the absolute BEST way to do double buffering with the GDI+:
First, add the following 3 lines into your form's constructor (the New method, where it says "put initialization code here"):
SetStyle(ControlStyles.AllPaintingInWmPaint, True)
SetStyle(ControlStyles.DoubleBuffer, True)
SetStyle(ControlStyles.UserPaint, True)
Now, draw all of your graphics in the Paint event. They will appear only after the Paint event terminates!
Finally, as I said, Image and Bitmap objects are slow. Their good for image manipulation, but definately NOT for speed. You'll be very lucky to render them at about 10 FPS (even with a fast computer), and it will take up all of your processing power and much of your RAM. If you need extra speed and more efficient use of system resources, create TextureBrush objects from your Image/Bitmap objects, and use those in your loops in place of the image and bitmap objects, or wherever you need the speed.
I havn't seen either of these tricks documented very well, and I've seen too many people make futile attempts to mimic them. I hope this helps you all out!