WinRT: how to save WriteableBitmap to localfolder

2019-04-13 18:01发布

问题:

How to save a WriteableBitmap to localfolder using C# in WinRT?

回答1:

You can check WinRT XAML Toolkit for a set of extension methods to do exactly what you need: http://winrtxamltoolkit.codeplex.com/SourceControl/changeset/view/0657c67a93d5#WinRTXamlToolkit%2fImaging%2fWriteableBitmapSaveExtensions.cs



回答2:

Here are bits and pieces of the answer

var bitmap = new WriteableBitmap(width,height);
var stream = bitmap.PixelBuffer.AsStream();

than you can get IOutputStream from Stream to write the data into the local folder.

this post explains how to convert Stream to byte[]

and this explains how to write byte[] array to localfolder.