void drawDoubleBufBmp()
{
Bitmap localBitmap = new Bitmap(settings.SizeX, settings.SizeY);
using (Graphics gx = Graphics.FromImage(localBitmap))
{
gx.DrawDrawString("Panz.....");
}
lock (BmpLock)
{
doubleBufBmp = localBitmap;
}
}
private Bitmap doubleBufBmp = new Bitmap(settings.SizeX, settings.SizeY);
private object BmpLock = new object();
protected override void OnPaint(PaintEventArgs e)
{
lock (BmpLock)
{
g.DrawImage(doubleBufBmp, 0, 0);
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{}
I had to overwrite
OnPaintBackground because this was causing the flickering. In the OnPaint function, I simply draw the complete doubleBufBmp in the Window. drawDoubleBufBmp() is called by a thread every 10 milliseconds, which then calls this.Invalidate(); which causes the OnPaint function to be called.
No comments:
Post a Comment