Aracılığıyla paylaş


RenderTargetBitmap.GetPixelsAsync Method

Definition

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

public:
 virtual IAsyncOperation<IBuffer ^> ^ GetPixelsAsync() = GetPixelsAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<IBuffer> GetPixelsAsync();
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<IBuffer> GetPixelsAsync();
function getPixelsAsync()
Public Function GetPixelsAsync () As IAsyncOperation(Of IBuffer)

Returns

An asynchronous operation object from which, on successful completion, you can retrieve 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

Attributes

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).

Applies to

See also