WriteableBitmap.Pixels Property
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets an array representing the 2-D texture of the bitmap.
Namespace: System.Windows.Media.Imaging
Assembly: System.Windows (in System.Windows.dll)
Syntax
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 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.
A WriteableBitmap constructed with the WriteableBitmap(Int32, Int32) overload will have an array length that is the product of the pixelWidth and pixelHeight inputs.
A WriteableBitmap constructed with the WriteableBitmap(UIElement, Transform) overload will have an array length that is the product of the pre-translated width and height of the input UIElement. Typically, you can precalculate the array length if you need to by using ActualHeight times ActualWidth.
A WriteableBitmap constructed with the WriteableBitmap(BitmapSource) overload will have an array length that is the product of PixelWidth and PixelHeight, but evaluation of the array length is asynchronous. The length is 1 initially.
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
Windows Phone OS
Supported in: 8.1, 8.0, 7.1, 7.0
Platforms
Windows Phone
See Also
Reference
System.Windows.Media.Imaging Namespace