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

Get Universal Windows® Apps with XAML and C# Unleashed now with O’Reilly online learning.

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