O'Reilly logo

XAML Unleashed by Adam Nathan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required