--- title: "How to: Manually Render Buffered Graphics" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "flicker [Windows Forms], reducing by manually rendering graphics" - "graphics [Windows Forms], rendering" ms.assetid: 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 class that is associated with drawing surfaces on your screen by calling the method. This method creates a instance that is associated with a particular rendering surface, such as a form or control. After you have created a instance, you can draw graphics to the buffer it represents through the property. After you have performed all graphics operations, you can copy the contents of the buffer to the screen by calling the method. > [!NOTE] > If you perform your own rendering, memory consumption will increase, though the increase may only be slight. ### To manually display buffered graphics 1. Obtain a reference to an instance of the class. For more information, see [How to: Manually Manage Buffered Graphics](how-to-manually-manage-buffered-graphics.md). 2. Create an instance of the class by calling the method, as shown in the following code example. [!code-csharp[System.Windows.Forms.LegacyBufferedGraphics#21](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/CS/Class1.cs#21)] [!code-vb[System.Windows.Forms.LegacyBufferedGraphics#21](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/VB/Class1.vb#21)] 3. Draw graphics to the graphics buffer by setting the property. For example: [!code-csharp[System.Windows.Forms.LegacyBufferedGraphics#22](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/CS/Class1.cs#22)] [!code-vb[System.Windows.Forms.LegacyBufferedGraphics#22](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/VB/Class1.vb#22)] 4. When you have completed all of your drawing operations to the graphics buffer, call the 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-csharp[System.Windows.Forms.LegacyBufferedGraphics#23](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/CS/Class1.cs#23)] [!code-vb[System.Windows.Forms.LegacyBufferedGraphics#23](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/VB/Class1.vb#23)] 5. After you are finished rendering graphics, call the `Dispose` method on the instance to free system resources. [!code-csharp[System.Windows.Forms.LegacyBufferedGraphics#24](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/CS/Class1.cs#24)] [!code-vb[System.Windows.Forms.LegacyBufferedGraphics#24](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.LegacyBufferedGraphics/VB/Class1.vb#24)] ## See also - - - [Double Buffered Graphics](double-buffered-graphics.md) - [How to: Manually Manage Buffered Graphics](how-to-manually-manage-buffered-graphics.md)