private void Sensor_ColorFrameAquired(object sender, FrameAquiredEventArgs e) { var softwareBitmap = e.Frame.VideoMediaFrame?.SoftwareBitmap; if (softwareBitmap == null) { return; } if (softwareBitmap.BitmapPixelFormat != Windows.Graphics.Imaging.BitmapPixelFormat.Bgra8 || softwareBitmap.BitmapAlphaMode != Windows.Graphics.Imaging.BitmapAlphaMode.Premultiplied) { softwareBitmap = SoftwareBitmap.Convert(softwareBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied); } softwareBitmap = Interlocked.Exchange(ref colorBuffer, softwareBitmap); softwareBitmap?.Dispose(); ColorImage.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { if (colorTaskRunning) { return; } colorTaskRunning = true; SoftwareBitmap latest; while ((latest = Interlocked.Exchange(ref colorBuffer, null)) != null) { var imageSource = (SoftwareBitmapSource)ColorImage.Source; await imageSource.SetBitmapAsync(latest); latest.Dispose(); } colorTaskRunning = false; }); }
private void Sensor_DepthFrameAquired(object sender, FrameAquiredEventArgs e) { }