WriteableBitmap.Unlock Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Liberta o buffer traseiro para o tornar disponível para exibição.
public:
void Unlock();
[System.Security.SecurityCritical]
public void Unlock();
public void Unlock();
[<System.Security.SecurityCritical>]
member this.Unlock : unit -> unit
member this.Unlock : unit -> unit
Public Sub Unlock ()
- Atributos
Exceções
O bitmap não foi bloqueado por uma chamada aos Lock() métodos ou.TryLock(Duration)
Exemplos
O seguinte exemplo de código mostra como libertar o back buffer usando o Unlock método.
// The DrawPixel method updates the WriteableBitmap by using
// unsafe code to write a pixel into the back buffer.
static void DrawPixel(MouseEventArgs e)
{
int column = (int)e.GetPosition(i).X;
int row = (int)e.GetPosition(i).Y;
try{
// Reserve the back buffer for updates.
writeableBitmap.Lock();
unsafe
{
// Get a pointer to the back buffer.
IntPtr pBackBuffer = writeableBitmap.BackBuffer;
// Find the address of the pixel to draw.
pBackBuffer += row * writeableBitmap.BackBufferStride;
pBackBuffer += column * 4;
// Compute the pixel's color.
int color_data = 255 << 16; // R
color_data |= 128 << 8; // G
color_data |= 255 << 0; // B
// Assign the color data to the pixel.
*((int*) pBackBuffer) = color_data;
}
// Specify the area of the bitmap that changed.
writeableBitmap.AddDirtyRect(new Int32Rect(column, row, 1, 1));
}
finally{
// Release the back buffer and make it available for display.
writeableBitmap.Unlock();
}
}
Observações
O Unlock método diminui a contagem de bloqueios. Quando a contagem de bloqueios atinge 0, é solicitada uma passagem de renderização se o AddDirtyRect método tiver sido chamado.