/// <summary> /// Pass the nput frame to a frame renderer and ensure proper image format is used /// </summary> /// <param name="inputVideoFrame"></param> /// <param name="useDX"></param> /// <returns></returns> public static IAsyncAction RenderFrameAsync(FrameRenderer frameRenderer, VideoFrame inputVideoFrame) { return(AsyncInfo.Run(async(token) => { bool useDX = inputVideoFrame.SoftwareBitmap == null; if (frameRenderer == null) { throw (new InvalidOperationException("FrameRenderer is null")); } SoftwareBitmap softwareBitmap = null; if (useDX) { softwareBitmap = await SoftwareBitmap.CreateCopyFromSurfaceAsync(inputVideoFrame.Direct3DSurface); softwareBitmap = SoftwareBitmap.Convert(softwareBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied); } else { softwareBitmap = new SoftwareBitmap( inputVideoFrame.SoftwareBitmap.BitmapPixelFormat, inputVideoFrame.SoftwareBitmap.PixelWidth, inputVideoFrame.SoftwareBitmap.PixelHeight, inputVideoFrame.SoftwareBitmap.BitmapAlphaMode); inputVideoFrame.SoftwareBitmap.CopyTo(softwareBitmap); } frameRenderer.RenderFrame(softwareBitmap); })); }
protected override void OnNavigatedTo(NavigationEventArgs e) { _resultframeRenderer = new FrameRenderer(UIResultImage); _inputFrameRenderer = new FrameRenderer(UIInputImage); }