C# 如何将图像从图像控制Win 8应用保存到文件夹

C# 如何将图像从图像控制Win 8应用保存到文件夹,c#,windows,xaml,windows-8,C#,Windows,Xaml,Windows 8,我有一个图像控件 <Image Name="img" HorizontalAlignment="Left" Height="400" Margin="499,155,0,0" VerticalAlignment="Top" Width="400"/> 现在我想把这个图像从img控件保存到文件夹中,但我不知道如何将图像从img控件解码到StorageFile private async void SaveFile_Click(object sender

我有一个图像控件

       <Image Name="img" HorizontalAlignment="Left"  Height="400" Margin="499,155,0,0" VerticalAlignment="Top" Width="400"/>
现在我想把这个图像从img控件保存到文件夹中,但我不知道如何将图像从img控件解码到StorageFile

        private async void SaveFile_Click(object sender, RoutedEventArgs e)
    {
        FileSavePicker savePicker = new FileSavePicker();
        savePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
        savePicker.FileTypeChoices.Add("jpeg image", new List<string>() { ".jpeg" });
        savePicker.SuggestedFileName = "New picture";

        StorageFile ff = await savePicker.PickSaveFileAsync();
        if (ff != null)
        {
            await photo.MoveAndReplaceAsync(ff);
        }
    }
private async void SaveFile\u单击(对象发送方,RoutedEventArgs e)
{
FileSavePicker savePicker=新FileSavePicker();
savePicker.SuggestedStartLocation=PickerLocationId.PicturesLibrary;
savePicker.FileTypeChoices.Add(“jpeg图像”,新列表(){.jpeg});
savePicker.SuggestedFileName=“新建图片”;
StorageFile ff=等待savePicker.PickSaveFileAsync();
如果(ff!=null)
{
等待照片。移动和放置异步(ff);
}
}
这是一种保存方法,我想从图像控件保存图像
       <Image Name="img" HorizontalAlignment="Left"  Height="400" Margin="499,155,0,0" VerticalAlignment="Top" Width="400"/>
var photo=wait camera.CaptureFileAsync(CameraCaptureUIMode.photo)返回一个存储文件。你所要做的就是把它保存到你想要的位置

你可以通过多种方式来实现这一点

例如:

StorageFolder localFolder = ApplicationData.Current.LocalFolder; // the app's local storage folder


await photo.MoveAsync(localFolder); //move the file to a new location
二,


注意
var photo==StorageFile photo
。这意味着在捕获照片后,它的副本已保存到本地存储上的临时位置(应用程序的TempState目录)。

但我想从另一个无法访问var photographic的方法保存此图像。您可以在类中使photo变量为public static,并在任何位置访问它。
//Create a new copy in a new location

await photo.CopyAsync(localFolder);