Getting Pixel Data

BitmapDecoder exposes a GetPixelDataAsync method that ultimately gives you a raw byte array with the image’s pixel data flattened into one dimension. However, this is done via an intermediate PixelDataProvider class as follows:

async Task UseDecoder(BitmapDecoder decoder){  PixelDataProvider provider = await decoder.GetPixelDataAsync();   byte[] pixels = provider.DetachPixelData();   ...}

DetachPixelData can be called only once per PixelDataProvider instance, because it does not hold onto a copy of the bytes.

BitmapDecoder has PixelWidth and PixelHeight properties that reveal the image’s dimensions, but without knowing the pixel format and alpha mode of the image, you can’t know how to interpret ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.