2 つのボタンとイメージ コントロールがあります。
最初のボタンをクリックすると、以下に示すように画像をロードしようとしています。
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
2番目のボタンをクリックすると、同じ画像にいくつかの変更を加えた後、その画像を写真ライブラリに保存する必要があります。
これは私がやろうとしていることであり、画像コントロールに既に読み込まれている画像を取得して保存する方法が混乱しています。
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