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

Generating Dynamic Images with WriteableBitmap

WriteableBitmap, the other BitmapSource subclass, is designed for displaying dynamic pixel content. You construct an instance with a specific width and height, modify its pixels exposed via a PixelBuffer property, and set it as the Source of an Image element.

One common point of confusion is that PixelBuffer is a useless-looking Windows Runtime interface called IBuffer. IBuffer exposes only two properties: Capacity (the maximum number of bytes it can hold) and Length (the number of bytes currently in use).

C++ code can query the object for the IBufferByteAccess COM interface to read/write its data, but this is not an option for an app’s C# code. Instead, you can use the DataReader and DataWriter ...

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