Double Buffer

  • Thread starter Thread starter sg
  • Start date Start date
S

sg

hi guys
do u have any idea how to do the double buffer in the compact framework? i
am actually using opennet cf's GDI code.. does someone have some samples?

cheers
 
Take a look at OpenNETCF.Windows.Forms.RoundGauge or OwnerDrawnList for
examples.

The main idea is to create a Bitmap object (offscreenBitmap), then by
using Graphics.FromImage you may get its Graphics object. All drawing
should come through this Graphics object. Then in OnPaint event draw
offscreenBitmap in the passed Graphics object.

Here is a small example how it can be done:


Bitmap offscreenBitmap;
Graphics offscreenGraphics;

....

offscreenBitmap = new Bitmap(Width, Height);
offscreenGraphics = Graphics.FromImage(offscreenBitmap);

....

protected override void OnPaint(PaintEventArgs e)
{
// all drawing goes here
// through "offscreenGraphics" object

e.Graphics.DrawImage(offscreenBitmap, 0, 0);
}

HTH
 
You can also take a look at this article:

http://msdn.microsoft.com/library/d...-us/dnnetcomp/html/ImageButton.asp?frame=true

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com
www.opennetcf.org

Sergey Bogdanov said:
Take a look at OpenNETCF.Windows.Forms.RoundGauge or OwnerDrawnList for
examples.

The main idea is to create a Bitmap object (offscreenBitmap), then by
using Graphics.FromImage you may get its Graphics object. All drawing
should come through this Graphics object. Then in OnPaint event draw
offscreenBitmap in the passed Graphics object.

Here is a small example how it can be done:


Bitmap offscreenBitmap;
Graphics offscreenGraphics;

...

offscreenBitmap = new Bitmap(Width, Height);
offscreenGraphics = Graphics.FromImage(offscreenBitmap);

...

protected override void OnPaint(PaintEventArgs e)
{
// all drawing goes here
// through "offscreenGraphics" object

e.Graphics.DrawImage(offscreenBitmap, 0, 0);
}

HTH

--
Sergey Bogdanov [.NET CF MVP, MCSD]
http://www.sergeybogdanov.com

hi guys
do u have any idea how to do the double buffer in the compact framework?
i am actually using opennet cf's GDI code.. does someone have some
samples?

cheers
 
Back
Top