Transcoding

Transcoding refers to the conversion of data from one encoding to another. So far, the encoding examples have created a new image (the silly gradient-filled image), but you can transcode an existing image by obtaining its current data via BitmapDecoder, feeding it into BitmapEncoder, and then changing it however you see fit.

You could do this by manually copying all pixel data and metadata obtained from the decoder over to the encoder, but BitmapEncoder has a nice shortcut for this scenario. Rather than creating a BitmapEncoder with its CreateAsync method, you can create one with its CreateForTranscodingAsync method. You simply give it the instance of the IRandomAccessStream that was given to a BitmapDecoder and the BitmapDecoder ...

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.