 |
|
 |
Brings me back to the good old amiga days! Double buffering was the buzz word back then.
This is just what I have been looking for
|
|
|
|
 |
|
 |
Have you done any benchmarking concerning the time it takes to do the rendering using the different double-buffer techniques you have presented?
Maybe you could include this in your test application?
Source code for the test application would be great too.
It could be worth mentioning the huge performance impact that you get if you use DrawImage instead of DrawImageUnscaled. Or maybe this doesn't apply in .NET 2 using OptimizedDoubleBuffer?
Good work.
|
|
|
|
 |
|
 |
hi Mikael
there is a source code included i don't know if you saw it but it demonstrates almost all this techniques.
about benchmarking every technique got it's own benefits so everyone who uses this much check his needs from what i have tested the manual way is sometimes better for the filling test while the OptimizedDoubleBuffer is usually better in the draw test.
about DrawImage and DrawImageUnScaled that depends on your graphic area if you keep it small i don't think u'll see much diffrent if any.
thanks for your commet Gil
|
|
|
|
 |
|
 |
Mikael Wiberg wrote: It could be worth mentioning the huge performance impact that you get if you use DrawImage instead of DrawImageUnscaled. Or maybe this doesn't apply in .NET 2 using OptimizedDoubleBuffer?
I hear this before, and actually there is no performance impact. DrawImageUnscaled is just one of many overloads of the DrawImage method.
//extracted from Reflector
public void DrawImageUnscaled(Image image, Point point)
{
this.DrawImage(image, point.X, point.Y);
}
|
|
|
|
 |
|
 |
hi givanfp
thanks for the comment i'll check it out
Gil
|
|
|
|
 |
|
 |
Hi,
good idea to make an overview on this topic but some points seem incomplete/wrong:
1. In your last sample/last line you use a variable ControlGraphics. I think in this sample it should be e.Graphics instead (always try your samples before posting them).
2. Same sample: You use this.CreateGraphics() to get a Graphics object. As there is already a Graphics object provided with the event arguments I'm not sure if this should be done (how about disposing?).
3. To be effective the allocation shouldn't be done within the Paint method. It can be done once and then forgot.
4. The new property Control.DoubleBuffered internally just call SetStyle with OptimizedDoubleBuffer and AllPaintingInWmPaint.
5. It would have been nice if you could have mentioned that own double buffering implementations have great flexibility. When painting into a bitmap you can reuse it the next time OnPaint is called unless you know something has changed.
|
|
|
|
 |
|
 |
hi Robert
first of all thanks for the commet.
this is the first version of this article i know that the code sample aren't good that's becouse i took them out of the source code itself and i built it a lot more efficiently , if you take a look at it you'll see that all your notes are in that code.
i had a choise of putting a small sample of each technique or putting a huge amont of code that i think a begginer won't understand/put the time into.
after seeing this first comment i will consider writing new small blocks of code to this article
thanks Gil
|
|
|
|
 |
|
 |
You didn't mention this in your article, but it should be mentioned in case any newbies run across this. In order for the ControlStyle DoubleBuffered or OptimizedDoubleBuffer to be effective, you also need to set two other styles:
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
Personally, for some controls which need to be repainted when they are resized, I also set another ControlStyle:
this.SetStyle(ControlStyles.ResizeRedraw, true);
This article did show me though how the BufferedGraphics classes could be used. Thanks!
|
|
|
|
 |
|
 |
hi Tim
thanks for the commet i'm working on an updated version of this article right now and i will put this changes into the updated version.
thanks Gil
|
|
|
|
 |
|
 |
Thanks for that, I was pulling my hair out trying to get a control to paint correctly.
|
|
|
|
 |
|
 |
- Is there any reason why you split up each code block into multiple <pre> sections? It would flow better if each code block was in a single <pre> section. If you wanted to put in blank lines, you can use <br/> instead
- Sentences begin with capital letters
- The word is "technique", not "technic"
Perhaps I'm being a little picky, but presentation is as important as content.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
 |
|
 |
hi Ryan
there's no special reason i edited the article on the online editor, and it was uneasy to work with, i will send an updated version of this article very soon.
thanks Gil
|
|
|
|
 |
|
 |
I downloaded your source code, (Download sourcecode - 12.46 kb). When I tried to build it on VS 2005 Express I encountered the below error message. If I am suppose to make some settings or references in the project, please be more specific.
Thanks.
Error 1 Resource file "Properties\Resources.resx" cannot be found. DoubleBuffering
|
|
|
|
 |
|
 |
hi firmwaredsp
i think you can still compile it by removing the reference but i will send an update version of this article in few days.
thanks Gil
|
|
|
|
 |
|
 |
This is the error message that was generated when I tried to build with VS2005 Express, your Updated as of 2/1/06 version.
Error 1 Source file '...\Properties\AssemblyInfo.cs' could not be opened ('The system cannot find the file specified. ')
-- modified at 3:31 Wednesday 1st February, 2006
|
|
|
|
 |
|
 |
One topic, explored well, I learnt something (didn't know about the .NET 2.0 changes with double buffering). Excellent. Thank-you
|
|
|
|
 |
|
 |
I agree, well done !
Matthew Hazlett
Sometimes I miss the simpler DOS days of Borland Turbo Pascal (but not very often).
|
|
|
|
 |
|
 |
Good timing - I've just coded a user drawn control and was going to go back and double-buffer it now I've got it working.
I would have used the old method as I didn't realise .NET 2.0 had these new features!
Thanks
Huw
|
|
|
|
 |