0
我正在嘗試構建相機應用程序。我可以拍照並保存。無法顯示拍攝的照片
但是繼承人的扭曲。如果我將照片保存在ApplicationData.Current.LocalFolder
中,我可以在Image
控件中顯示它。但是,當我將它保存在KnownFolders.CameraRoll
中時,Image
控件不會加載照片。
該照片顯示在手機的相冊(照片)中,所以不是該文件未創建。我也添加了圖片庫功能。 Theres甚至沒有例外!
async private void Capture_Photo_Click(object sender, RoutedEventArgs e)
{
//Create JPEG image Encoding format for storing image in JPEG type
ImageEncodingProperties imgFormat = ImageEncodingProperties.CreateJpeg();
//create storage file in local app storage
//StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("Photo.jpg",CreationCollisionOption.ReplaceExisting);
//// create storage file in Picture Library
StorageFile file = await KnownFolders.CameraRoll.CreateFileAsync("Photo.jpg", CreationCollisionOption.GenerateUniqueName);
// take photo and store it on file location.
await captureManager.CapturePhotoToStorageFileAsync(imgFormat, file);
// Get photo as a BitmapImage using storage file path.
BitmapImage img = new BitmapImage();
BitmapImage bmpImage = new BitmapImage(new Uri(file.Path));
// show captured image on Image UIElement.
imagePreivew.Source = bmpImage;
}
工作!謝謝 :) –