public async Task GetNewFrameAndApplyEffect(IBuffer frameBuffer, Size frameSize) { if (_semaphore.WaitOne(500)) { _cameraPreviewImageSource.InvalidateLoad(); var scanlineByteSize = (uint)frameSize.Width * 4; // 4 bytes per pixel in BGRA888 mode var bitmap = new Bitmap(frameSize, ColorMode.Bgra8888, scanlineByteSize, frameBuffer); if (_filterEffect != null) { var renderer = new BitmapRenderer(_filterEffect, bitmap); await renderer.RenderAsync(); } else if (_customEffect != null) { var renderer = new BitmapRenderer(_customEffect, bitmap); await renderer.RenderAsync(); } else { var renderer = new BitmapRenderer(_cameraPreviewImageSource, bitmap); await renderer.RenderAsync(); } _semaphore.Release(); } }