共用方式為


WriteableBitmap.WritePixels 方法

定義

更新可寫入之點陣圖的像素。

多載

WritePixels(Int32Rect, Array, Int32, Int32)

更新指定之點陣圖區域中的像素。

WritePixels(Int32Rect, IntPtr, Int32, Int32)

更新指定之點陣圖區域中的像素。

WritePixels(Int32Rect, Array, Int32, Int32, Int32)

更新指定之點陣圖區域中的像素。

WritePixels(Int32Rect, IntPtr, Int32, Int32, Int32, Int32)

更新指定之點陣圖區域中的像素。

WritePixels(Int32Rect, Array, Int32, Int32)

更新指定之點陣圖區域中的像素。

public:
 void WritePixels(System::Windows::Int32Rect sourceRect, Array ^ pixels, int stride, int offset);
[System.Security.SecurityCritical]
public void WritePixels (System.Windows.Int32Rect sourceRect, Array pixels, int stride, int offset);
public void WritePixels (System.Windows.Int32Rect sourceRect, Array pixels, int stride, int offset);
[<System.Security.SecurityCritical>]
member this.WritePixels : System.Windows.Int32Rect * Array * int * int -> unit
member this.WritePixels : System.Windows.Int32Rect * Array * int * int -> unit
Public Sub WritePixels (sourceRect As Int32Rect, pixels As Array, stride As Integer, offset As Integer)

參數

sourceRect
Int32Rect

要更新的 WriteableBitmap 的矩形。

pixels
Array

用來更新點陣圖的像素陣列。

stride
Int32

更新區域的步距 (Stride),以 pixels 為單位。

offset
Int32

輸入緩衝區的位移。

屬性

例外狀況

下列一或多個條件為 True。

sourceRect 落在 WriteableBitmap 範圍之外。

stride< 1

offset< 0

pixelsnull

pixels 的順位 (Rank) 不是 1 或 2,或其長度小於或等於 0。

範例

下列程式碼範例示範如何使用 方法來更新後端緩衝區 WritePixels 中的圖元。

static void ErasePixel(MouseEventArgs e)
{
    byte[] ColorData = { 0, 0, 0, 0 }; // B G R

    Int32Rect rect = new Int32Rect(
            (int)(e.GetPosition(i).X), 
            (int)(e.GetPosition(i).Y), 
            1, 
            1);

    writeableBitmap.WritePixels( rect, ColorData, 4, 0);
}

備註

WritePixels(Int32Rect, Array, Int32, Int32, Int32)WritePixels(Int32Rect, IntPtr, Int32, Int32, Int32, Int32) 多載是偏好使用這個方法。

注意

在部分信任中 WritePixels(Int32Rect, Array, Int32, Int32, Int32) ,使用 多載。

適用於

WritePixels(Int32Rect, IntPtr, Int32, Int32)

更新指定之點陣圖區域中的像素。

public:
 void WritePixels(System::Windows::Int32Rect sourceRect, IntPtr buffer, int bufferSize, int stride);
[System.Security.SecurityCritical]
public void WritePixels (System.Windows.Int32Rect sourceRect, IntPtr buffer, int bufferSize, int stride);
public void WritePixels (System.Windows.Int32Rect sourceRect, IntPtr buffer, int bufferSize, int stride);
[<System.Security.SecurityCritical>]
member this.WritePixels : System.Windows.Int32Rect * nativeint * int * int -> unit
member this.WritePixels : System.Windows.Int32Rect * nativeint * int * int -> unit
Public Sub WritePixels (sourceRect As Int32Rect, buffer As IntPtr, bufferSize As Integer, stride As Integer)

參數

sourceRect
Int32Rect

要更新的 WriteableBitmap 的矩形。

buffer
IntPtr

nativeint

用來更新點陣圖的輸入緩衝區。

bufferSize
Int32

輸入緩衝區的大小。

stride
Int32

更新區域的步距 (Stride),以 buffer 為單位。

屬性

例外狀況

下列一或多個條件為 True。

sourceRect 落在 WriteableBitmap 範圍之外。

bufferSize< 1

stride< 1

buffernull

備註

WritePixels(Int32Rect, Array, Int32, Int32, Int32)WritePixels(Int32Rect, IntPtr, Int32, Int32, Int32, Int32) 多載是偏好使用這個方法。

注意

在部分信任中 WritePixels(Int32Rect, Array, Int32, Int32, Int32) ,使用 多載。

適用於

WritePixels(Int32Rect, Array, Int32, Int32, Int32)

更新指定之點陣圖區域中的像素。

public:
 void WritePixels(System::Windows::Int32Rect sourceRect, Array ^ sourceBuffer, int sourceBufferStride, int destinationX, int destinationY);
[System.Security.SecurityCritical]
public void WritePixels (System.Windows.Int32Rect sourceRect, Array sourceBuffer, int sourceBufferStride, int destinationX, int destinationY);
public void WritePixels (System.Windows.Int32Rect sourceRect, Array sourceBuffer, int sourceBufferStride, int destinationX, int destinationY);
[<System.Security.SecurityCritical>]
member this.WritePixels : System.Windows.Int32Rect * Array * int * int * int -> unit
member this.WritePixels : System.Windows.Int32Rect * Array * int * int * int -> unit
Public Sub WritePixels (sourceRect As Int32Rect, sourceBuffer As Array, sourceBufferStride As Integer, destinationX As Integer, destinationY As Integer)

參數

sourceRect
Int32Rect

sourceBuffer 中要複製的矩形。

sourceBuffer
Array

用來更新點陣圖的輸入緩衝區。

sourceBufferStride
Int32

輸入緩衝區的步距,以位元組為單位。

destinationX
Int32

背景緩衝區中最左邊像素的目的 X 座標。

destinationY
Int32

背景緩衝區中最頂端像素的目的 Y 座標。

屬性

例外狀況

下列一或多個條件為 True。

sourceRect 落在 WriteableBitmap 範圍之外。

destinationXdestinationY 落在 WriteableBitmap 範圍以外。

sourceBufferStride< 1

sourceBuffernull

sourceBuffer 的順位 (Rank) 不是 1 或 2,或其長度小於或等於 0。

備註

呼叫 方法, WritePixels 使用 WriteableBitmap 的內容 sourceBuffer 自動更新 。 呼叫這個方法相當於使用 Lock 類別備註中所述的 WriteableBitmapUnlock 工作流程。

注意

在部分信任中使用這個多載。

另請參閱

適用於

WritePixels(Int32Rect, IntPtr, Int32, Int32, Int32, Int32)

更新指定之點陣圖區域中的像素。

public:
 void WritePixels(System::Windows::Int32Rect sourceRect, IntPtr sourceBuffer, int sourceBufferSize, int sourceBufferStride, int destinationX, int destinationY);
[System.Security.SecurityCritical]
public void WritePixels (System.Windows.Int32Rect sourceRect, IntPtr sourceBuffer, int sourceBufferSize, int sourceBufferStride, int destinationX, int destinationY);
public void WritePixels (System.Windows.Int32Rect sourceRect, IntPtr sourceBuffer, int sourceBufferSize, int sourceBufferStride, int destinationX, int destinationY);
[<System.Security.SecurityCritical>]
member this.WritePixels : System.Windows.Int32Rect * nativeint * int * int * int * int -> unit
member this.WritePixels : System.Windows.Int32Rect * nativeint * int * int * int * int -> unit
Public Sub WritePixels (sourceRect As Int32Rect, sourceBuffer As IntPtr, sourceBufferSize As Integer, sourceBufferStride As Integer, destinationX As Integer, destinationY As Integer)

參數

sourceRect
Int32Rect

sourceBuffer 中要複製的矩形。

sourceBuffer
IntPtr

nativeint

用來更新點陣圖的輸入緩衝區。

sourceBufferSize
Int32

輸入緩衝區的大小。

sourceBufferStride
Int32

輸入緩衝區的步距,以位元組為單位。

destinationX
Int32

背景緩衝區中最左邊像素的目的 X 座標。

destinationY
Int32

背景緩衝區中最頂端像素的目的 Y 座標。

屬性

例外狀況

下列一或多個條件為 True。

sourceRect 落在 WriteableBitmap 範圍之外。

destinationXdestinationY 落在 WriteableBitmap 範圍以外。

sourceBufferSize< 1

sourceBufferStride< 1

sourceBuffernull

備註

呼叫 方法, WritePixels 使用 WriteableBitmap 的內容 sourceBuffer 自動更新 。 呼叫這個方法相當於使用 Lock 類別備註中所述的 WriteableBitmapUnlock 工作流程。

注意

在部分信任中 WritePixels(Int32Rect, Array, Int32, Int32, Int32) ,使用 多載。

另請參閱

適用於