SoftwareBitmap
をWriteableBitmap
に変換するたびに、次の例外が発生します。 System.Runtime.InteropServices.COMException
ここでSoftwareBitmapをWriteableBitmapに変換する
は、そのための私のコードスニペットです:
private async void Start(object sender, RoutedEventArgs e)
{
_MediaCapture = new MediaCapture();
await _MediaCapture.InitializeAsync();
mediaElement.Source = _MediaCapture;
await _MediaCapture.StartPreviewAsync();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 1);
timer.Tick += HandleTimerTick;
timer.Start();
}
private async void HandleTimerTick(object Sender, object E)
{
var frame = await _MediaCapture.GetPreviewFrameAsync();
SoftwareBitmap frameBitmap = frame.SoftwareBitmap;
WriteableBitmap bitmap = new WriteableBitmap(frameBitmap.PixelWidth, frameBitmap.PixelHeight);
try
{
frameBitmap.CopyToBuffer(bitmap.PixelBuffer);
}
catch (Exception)
{
Debug.WriteLine("Exception ");
}
}
ライン
frameBitmap.CopyToBuffer(bitmap.PixelBuffer);
は例外をスローしています。
これはx64 RemoteDeviceでデバッグしています。
は例外が何を投げていますか? –
@Dmitry Bychenko上記を参照してください:System.Runtime.InteropServices.COMException – TheTanic
サイドノート:「catch(Exception){Debug.WriteLine( "Exception");}のような例外をスワッピングします。 } 'は非常に悪い練習です*。 –