Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Se você estiver gerenciando seus próprios gráficos em buffer, precisará ser capaz de criar e renderizar buffers gráficos. Você pode criar instâncias da BufferedGraphics classe associadas a superfícies de desenho na tela chamando o Allocate método. Esse método cria uma BufferedGraphics instância associada a uma superfície de renderização específica, como um formulário ou controle. Depois de criar uma BufferedGraphics instância, você pode desenhar gráficos para o buffer que ele representa por meio da Graphics propriedade. Depois de executar todas as operações gráficas, você pode copiar o conteúdo do buffer para a tela chamando o Render método.
Observação
Se você executar sua própria renderização, o consumo de memória aumentará, embora o aumento possa ser apenas pequeno.
Para exibir manualmente gráficos em buffer
Obtenha uma referência a uma instância da BufferedGraphicsContext classe. Para obter mais informações, consulte Como gerenciar manualmente gráficos em buffer.
Crie uma instância da BufferedGraphics classe chamando o Allocate método, conforme mostrado no exemplo de código a seguir.
// 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)Desenhe gráficos para o buffer de gráficos definindo a Graphics propriedade. Por exemplo:
// 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)Quando você concluir todas as operações de desenho no buffer gráfico, chame o método Render para renderizar o buffer, seja na superfície de desenho associada a esse buffer ou em uma superfície de desenho especificada, conforme mostrado no exemplo de código a seguir.
// 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)Depois de concluir a renderização de elementos gráficos, chame o
Disposemétodo na BufferedGraphics instância para liberar recursos do sistema.myBuffer.Dispose();myBuffer.Dispose()
Consulte também
.NET Desktop feedback