RenderTargetBitmap.GetPixelsAsync method

Applies to Windows and Windows Phone

Retrieves the previously rendered RenderTargetBitmap image as a buffered stream of bytes in BGRA8 format.

Syntax


public IAsyncOperation<IBuffer> GetPixelsAsync()

Parameters

This method has no parameters.

Return value

Type: IAsyncOperation<IBuffer>

When this method returns, an IBuffer stream that contains bytes. This is the binary data for the image and can be converted to a byte array in BGRA8 format

Remarks

The IBuffer return value enables passing the result to a WriteableBitmap and its PixelBuffer. Another alternative is passing the buffer to a BitmapEncoder. If you want an array of bytes, use a DataReader and the FromBuffer method to help with the conversion.

Through the IAsyncOperation intermediate value, this method returns the pixels of the image source that was produced by the most recent call to RenderAsync.

Always call RenderAsync before calling GetPixelsAsync. If you call GetPixelsAsync and never called RenderAsync previously on that RenderTargetBitmap instance, GetPixelsAsync will return an empty buffer stream, and no error will occur (async Status is Completed, so you can't use that as an indicator).

Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Media.Imaging
Windows::UI::Xaml::Media::Imaging [C++]

Metadata

Windows.winmd

See also

RenderTargetBitmap
BitmapEncoder
DataTransferManager
Windows.Graphics.Imaging namespace
XAML render to bitmap sample

 

 

Show:
© 2014 Microsoft