CameraCaptureUI 在指定位置保存图片
CameraCaptureUI Save picture at specified location
我正在使用 CameraCaptureUI API 在 windows 平板电脑上拍照。我可以拍照,但我不知道它保存在哪里或如何更改它的保存文件夹。
我试过用下面的代码将它保存到图片库中,但没有成功:
Dim fileCopy As StorageFile = Await file.CopyAsync(KnownFolders.PicturesLibrary, "MyNicePhoto.bmp", NameCollisionOption.ReplaceExisting)
这是我用来拍照的代码(取自 CameraCaptureUI 示例)
Private appSettings As Windows.Foundation.Collections.IPropertySet
Private Const photoKey As String = "capturedPhoto"
Try
' Using Windows.Media.Capture.CameraCaptureUI API to capture a photo
Dim dialog As New CameraCaptureUI()
Dim aspectRatio As New Size(16, 9)
dialog.PhotoSettings.CroppedAspectRatio = aspectRatio
Dim file As StorageFile = Await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo)
If file IsNot Nothing Then
Dim bitmapImage As New BitmapImage()
Using fileStream As IRandomAccessStream = Await file.OpenAsync(FileAccessMode.Read)
bitmapImage.SetSource(fileStream)
End Using
' Store the file path in Application Data
appSettings(photoKey) = file.Path
End If
Catch ex As Exception
End Try
使用此代码将图片保存到某处吗?
如果有,知道在哪里吗?
如何更改保存位置?
我不是 100% 确定这就是您想要的,但它可能会有所帮助:
Dim saveDiag As New Pickers.FolderPicker
Dim destFolder As Windows.Storage.StorageFolder = Await SaveDiag.PickSingleFolderAsync
Await file.MoveAsync(destFolder)
我正在使用 CameraCaptureUI API 在 windows 平板电脑上拍照。我可以拍照,但我不知道它保存在哪里或如何更改它的保存文件夹。
我试过用下面的代码将它保存到图片库中,但没有成功:
Dim fileCopy As StorageFile = Await file.CopyAsync(KnownFolders.PicturesLibrary, "MyNicePhoto.bmp", NameCollisionOption.ReplaceExisting)
这是我用来拍照的代码(取自 CameraCaptureUI 示例)
Private appSettings As Windows.Foundation.Collections.IPropertySet
Private Const photoKey As String = "capturedPhoto"
Try
' Using Windows.Media.Capture.CameraCaptureUI API to capture a photo
Dim dialog As New CameraCaptureUI()
Dim aspectRatio As New Size(16, 9)
dialog.PhotoSettings.CroppedAspectRatio = aspectRatio
Dim file As StorageFile = Await dialog.CaptureFileAsync(CameraCaptureUIMode.Photo)
If file IsNot Nothing Then
Dim bitmapImage As New BitmapImage()
Using fileStream As IRandomAccessStream = Await file.OpenAsync(FileAccessMode.Read)
bitmapImage.SetSource(fileStream)
End Using
' Store the file path in Application Data
appSettings(photoKey) = file.Path
End If
Catch ex As Exception
End Try
使用此代码将图片保存到某处吗?
如果有,知道在哪里吗?
如何更改保存位置?
我不是 100% 确定这就是您想要的,但它可能会有所帮助:
Dim saveDiag As New Pickers.FolderPicker
Dim destFolder As Windows.Storage.StorageFolder = Await SaveDiag.PickSingleFolderAsync
Await file.MoveAsync(destFolder)