Compartilhar via


WriteableBitmap.Pixels Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets an array representing the 2-D texture of the bitmap.

Namespace:  System.Windows.Media.Imaging
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public ReadOnly Property Pixels As Integer()
public int[] Pixels { get; }

Property Value

Type: array<System.Int32[]
An array of integers representing the 2-D texture of the bitmap.

Exceptions

Exception Condition
SecurityException

The WriteableBitmap is created from protected content. The Pixels array is inaccessible in this case.

Remarks

When assigning colors to pixels in your bitmap, use pre-multiplied colors. The format used by the Silverlight WriteableBitmap is ARGB32 (premultiplied RGB). Similarly, if reading values from the array, treat these as ARGB32 (premultiplied RGB) values if you are reprocessing or rendering based on the values.

The length of the array is based on construction behavior.

Position of pixels in the array is that .Pixels[0] is the upper left corner of the image. .Pixels[1] is the pixel in the same row and to the immediate right, and so on. Scenarios that use WriteableBitmap either for algorithm-created images or for image format conversion typically use the Pixels array as part of a loop that goes through the entire array and sets integer values, representing the format pixels of the desired image.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.