Ich versuche, die Kamera in einer Windows 10 Mobile App zu verwenden, aber ein Fehler tritt auf, wenn ich das Bild mache und versuche, es auf dem Bildschirm zu zeigen.Windows 10 mobile Kamera
Hier ist der Code:
CameraCaptureUI captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.Format = CameraCaptureUIPhotoFormat.Jpeg;
captureUI.PhotoSettings.CroppedSizeInPixels = new Size(200, 200);
StorageFile photo = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
if (photo == null)
{
// User cancelled photo capture
return;
}
StorageFolder destinationFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("ProfilePhotoFolder", CreationCollisionOption.OpenIfExists);
await photo.CopyAsync(destinationFolder, "ProfilePhoto.jpg", NameCollisionOption.ReplaceExisting);
await photo.DeleteAsync();
IRandomAccessStream stream = await photo.OpenAsync(FileAccessMode.Read);
BitmapDecoder decoder = await BitmapDecoder.CreateAsync(stream);
SoftwareBitmap softwareBitmap = await decoder.GetSoftwareBitmapAsync();
SoftwareBitmap softwareBitmapBGR8 = SoftwareBitmap.Convert(softwareBitmap,
BitmapPixelFormat.Bgra8,
BitmapAlphaMode.Premultiplied);
SoftwareBitmapSource bitmapSource = new SoftwareBitmapSource();
await bitmapSource.SetBitmapAsync(softwareBitmapBGR8);
imageControl.Source = bitmapSource;
Die Meldung Ausnahme:
Eine Ausnahme vom Typ 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll aufgetreten war aber nicht behandelt im Benutzercode
Weitere Informationen: Das System kann die angegebene Datei nicht finden. (Ausnahme von HRESULT: 0x80070002)
Wenn es einen Handler für diese Ausnahme ist, kann das Programm sicher fortgesetzt werden „
Jemand mir helfen kann mit diesem
Haben Sie das Problem gelöst? –
Ja, hat es getan. Vielen Dank! –