How to

render buffered graphics

Published: 20. January 2009 | Updated: 20. January 2009
License: Microsoft Public License (MS-PL)
Categories: GDI
Tags: C# Controls GDI Winforms
Was this snippet helpful for you? YESYES / NONO

To get more information about buffered graphics see http://msdn.microsoft.com/en-us/library/b367a457.aspx

Import namespace

using System.Drawing;

Code

// get graphics context and create buffer
BufferedGraphicsContext context = BufferedGraphicsManager.Current;
BufferedGraphics buffer = context.Allocate(this.CreateGraphics(), this.DisplayRectangle);

// draw to buffer
buffer.Graphics.FillRectangle(Brushes.Green, this.DisplayRectangle);
buffer.Graphics.DrawIcon(SystemIcons.Hand, this.DisplayRectangle);

// renders content of buffer to drawing surface
buffer.Render();
buffer.Dispose();
Send us feedback about this snippet »



Related Snippets: