* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
4.0 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||
|---|---|---|---|---|---|---|---|---|
| How to: Manually Render Buffered Graphics | 03/30/2017 |
|
|
5192295e-bd8e-45f7-8bd6-5c4f6bd21e61 |
How to: Manually Render Buffered Graphics
If you are managing your own buffered graphics, you will need to be able to create and render graphics buffers. You can create instances of the xref:System.Drawing.BufferedGraphics class that is associated with drawing surfaces on your screen by calling the xref:System.Drawing.BufferedGraphicsContext.Allocate%2A method. This method creates a xref:System.Drawing.BufferedGraphics instance that is associated with a particular rendering surface, such as a form or control. After you have created a xref:System.Drawing.BufferedGraphics instance, you can draw graphics to the buffer it represents through the xref:System.Drawing.BufferedGraphics.Graphics%2A property. After you have performed all graphics operations, you can copy the contents of the buffer to the screen by calling the xref:System.Drawing.BufferedGraphics.Render%2A method.
Note
If you perform your own rendering, memory consumption will increase, though the increase may only be slight.
To manually display buffered graphics
-
Obtain a reference to an instance of the xref:System.Drawing.BufferedGraphicsContext class. For more information, see How to: Manually Manage Buffered Graphics.
-
Create an instance of the xref:System.Drawing.BufferedGraphics class by calling the xref:System.Drawing.BufferedGraphicsContext.Allocate%2A method, as shown in the following code example.
[!code-csharpSystem.Windows.Forms.LegacyBufferedGraphics#21] [!code-vbSystem.Windows.Forms.LegacyBufferedGraphics#21]
-
Draw graphics to the graphics buffer by setting the xref:System.Drawing.BufferedGraphics.Graphics%2A property. For example:
[!code-csharpSystem.Windows.Forms.LegacyBufferedGraphics#22] [!code-vbSystem.Windows.Forms.LegacyBufferedGraphics#22]
-
When you have completed all of your drawing operations to the graphics buffer, call the xref:System.Drawing.BufferedGraphics.Render%2A method to render the buffer, either to the drawing surface associated with that buffer, or to a specified drawing surface, as shown in the following code example.
[!code-csharpSystem.Windows.Forms.LegacyBufferedGraphics#23] [!code-vbSystem.Windows.Forms.LegacyBufferedGraphics#23]
-
After you are finished rendering graphics, call the
Disposemethod on the xref:System.Drawing.BufferedGraphics instance to free system resources.[!code-csharpSystem.Windows.Forms.LegacyBufferedGraphics#24] [!code-vbSystem.Windows.Forms.LegacyBufferedGraphics#24]