.net 在Windows应用商店应用程序中保存图像

.net 在Windows应用商店应用程序中保存图像,.net,vb.net,image,save,windows-store-apps,.net,Vb.net,Image,Save,Windows Store Apps,我有两个按钮和一个图像控件 现在,当我单击第一个按钮时,我正试图加载一个图像,如下所示 Dim openPicker As New FileOpenPicker openPicker.ViewMode = PickerViewMode.Thumbnail openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary openPicker.FileTypeFilter.Add(".jpg")

我有两个按钮和一个图像控件

现在,当我单击第一个按钮时,我正试图加载一个图像,如下所示

 Dim openPicker As New FileOpenPicker
    openPicker.ViewMode = PickerViewMode.Thumbnail
    openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary
    openPicker.FileTypeFilter.Add(".jpg")
    openPicker.FileTypeFilter.Add(".jpeg")
    openPicker.FileTypeFilter.Add(".png")
    Dim file As StorageFile = Await openPicker.PickSingleFileAsync
    If Nothing IsNot file Then
        Dim image As New BitmapImage()
        Dim stream = Await file.OpenAsync(Windows.Storage.FileAccessMode.Read)
        image.SetSource(stream)
        Image1.Source = image
        LayoutRoot.Visibility = Windows.UI.Xaml.Visibility.Collapsed
        txtImgdisplay.Text = file.Path 
    Else
        txtImgdisplay.Text = "Invalid File"
    End If
现在,当我单击第二个按钮时,我需要在对同一图像进行一些修改后将该图像保存到图片库

这就是我正在尝试做的,并且弄不清楚如何获取已经加载到图像控件中的图像并保存它

 Dim fileSavePicker As New FileSavePicker()
    fileSavePicker.FileTypeChoices.Add("PNG", New String() {".png"})
    fileSavePicker.FileTypeChoices.Add("JPG", New String() {".jpg"})
    fileSavePicker.FileTypeChoices.Add("BMP", New String() {".bmp"})
    fileSavePicker.FileTypeChoices.Add("TIFF", New String() {".tiff"})
    fileSavePicker.FileTypeChoices.Add("EXIF", New String() {".exif"})
    fileSavePicker.FileTypeChoices.Add("ICO", New String() {".ico"})
    Dim saveFile As StorageFile = Await fileSavePicker.PickSaveFileAsync()

    If Nothing IsNot saveFile Then
        Dim image As New BitmapImage()
        Dim stream = Await StorageFile.GetFileFromPathAsync(txtImgdisplay.Text)
        LayoutRoot.Visibility = Windows.UI.Xaml.Visibility.Collapsed
        txtImgdisplay.Text = saveFile.Path
        Image1.Source = image
        Dim copyFile As StorageFile = Await saveFile.CopyAsync(Windows.Storage.KnownFolders.PicturesLibrary, "sample - Copy.png")
    Else
        txtImgdisplay.Text = "Invalid File"
    End If

我相信您所需要做的就是调用位图对象的Save方法

image.Save(pathToPictureFolder & filename)
尝试如下。 1) 将所选文件(StorageFile)存储为成员变量。 2) 单击第二个按钮时

FolderPicker saveFolder=新FolderPicker()
saveFolder.SuggestedStartLocation=PickerLocationId.Desktop
saveFolder.FileTypeFilter.Add(“*”); StorageFolder storagefolderSave=等待saveFolder.PickSingleFolderAsync(); StorageFile storagefileSave=[选择StorageFile作为成员变量] 等待storagefileSave.CopySync(storagefolderSave、storagefileSave.Name、NameCollisionOption.ReplaceExisting)


@A非常感谢您的回复。但是没有保存图像的方法。我很抱歉。我误读了你的代码,认为它是位图,而不是位图。没问题。不需要道歉:)从今天早上开始撞我的头,但我想不出来。