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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.