Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Als u uw eigen gebufferde afbeeldingen beheert, moet u grafische buffers kunnen maken en weergeven. U kunt exemplaren maken van de BufferedGraphics-klasse die is gekoppeld aan tekenoppervlakken op het scherm door de methode Allocate aan te roepen. Met deze methode maakt u een BufferedGraphics exemplaar dat is gekoppeld aan een bepaald renderingoppervlak, zoals een formulier of besturingselement. Nadat u een BufferedGraphics-exemplaar hebt gemaakt, kunt u afbeeldingen tekenen in de buffer die deze vertegenwoordigt via de eigenschap Graphics. Nadat u alle grafische bewerkingen hebt uitgevoerd, kunt u de inhoud van de buffer naar het scherm kopiƫren door de methode Render aan te roepen.
Opmerking
Als u uw eigen rendering uitvoert, neemt het geheugenverbruik toe, hoewel de toename mogelijk slechts gering is.
Handmatig gebufferde afbeeldingen weergeven
Haal een verwijzing op naar een object van de BufferedGraphicsContext klasse. Zie voor meer informatie Procedure: Handmatig bufferafbeeldingen beheren.
Maak een exemplaar van de klasse BufferedGraphics door de Allocate methode aan te roepen, zoals wordt weergegeven in het volgende codevoorbeeld.
// This example assumes the existence of a form called Form1. BufferedGraphicsContext currentContext; BufferedGraphics myBuffer; // Gets a reference to the current BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current; // Creates a BufferedGraphics instance associated with Form1, and with // dimensions the same size as the drawing surface of Form1. myBuffer = currentContext.Allocate(this.CreateGraphics(), this.DisplayRectangle);' This example assumes the existence of a form called Form1. Dim currentContext As BufferedGraphicsContext Dim myBuffer As BufferedGraphics ' Gets a reference to the current BufferedGraphicsContext. currentContext = BufferedGraphicsManager.Current ' Creates a BufferedGraphics instance associated with Form1, and with ' dimensions the same size as the drawing surface of Form1. myBuffer = currentContext.Allocate(Me.CreateGraphics, _ Me.DisplayRectangle)Teken afbeeldingen naar de grafische buffer door de eigenschap Graphics in te stellen. Voorbeeld:
// Draws an ellipse to the graphics buffer. myBuffer.Graphics.DrawEllipse(Pens.Blue, this.DisplayRectangle);' Draws an ellipse to the graphics buffer. myBuffer.Graphics.DrawEllipse(Pens.Blue, Me.DisplayRectangle)Wanneer u al uw tekenbewerkingen naar de grafische buffer hebt voltooid, roept u de Render methode aan om de buffer weer te geven, hetzij op het tekenoppervlak dat aan die buffer is gekoppeld, of op een opgegeven tekenoppervlak, zoals wordt weergegeven in het volgende codevoorbeeld.
// This example assumes the existence of a BufferedGraphics instance // called myBuffer. // Renders the contents of the buffer to the drawing surface associated // with the buffer. myBuffer.Render(); // Renders the contents of the buffer to the specified drawing surface. myBuffer.Render(this.CreateGraphics());' Renders the contents of the buffer to the drawing surface associated ' with the buffer. myBuffer.Render() ' Renders the contents of the buffer to the specified drawing surface. myBuffer.Render(Me.CreateGraphics)Nadat u klaar bent met het weergeven van afbeeldingen, roept u de
Disposemethode op het BufferedGraphics exemplaar aan om systeembronnen vrij te maken.myBuffer.Dispose();myBuffer.Dispose()
Zie ook
.NET Desktop feedback