正如你所提供的the link那么我假设你设法得到了存储文件 after 延续(这就是它在 WP8.1 运行时的工作方式)。
我还假设你有一个Stream与您的图像或您知道如何获得这样的图像。基于这两个,您可以将图像保存在png格式为选择器选择的文件,例如如下所示:
public async Task SaveStreamAsync(IRandomAccessStream streamToSave, StorageFile destination)
{
BitmapDecoder bmpDecoder = await BitmapDecoder.CreateAsync(streamToSave);
PixelDataProvider pixelData = await bmpDecoder.GetPixelDataAsync(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Straight, null, ExifOrientationMode.RespectExifOrientation, ColorManagementMode.DoNotColorManage);
using (var destFileStream = await destination.OpenAsync(FileAccessMode.ReadWrite))
{
BitmapEncoder bmpEncoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, destFileStream);
uint yourWidthAndOrHeight = 1024;
bmpEncoder.SetPixelData(BitmapPixelFormat.Rgba8, BitmapAlphaMode.Straight, yourWidthAndOrHeight, yourWidthAndOrHeight, 300, 300, pixelData.DetachPixelData());
await bmpEncoder.FlushAsync();
}
}
还请记得Dispose
your streamToSave
(和其他资源)在与他们合作完成后。
如果你看一下位图编码器 and 位图解码器类,然后您将看到更多选项,包括转换和各种属性。
(我没有粗略地测试上面的代码,但希望它能正常工作)