public ColorFrameBitmap(PlayColorFrame frame) { // force population of PixelFormat var data = frame.GetFrameDataAsync().Result; _bitmap = new WriteableBitmap(frame.Width, frame.Height, 96, 96, frame.Codec.PixelFormat, null); _bytes = new byte[_bitmap.PixelWidth * _bitmap.PixelHeight * (_bitmap.Format.BitsPerPixel / 8)]; _dirtyRect = new Int32Rect(0, 0, frame.Width, frame.Height); }
public void Update(PlayColorFrame frame) { if (frame != null) { frame.GetFrameDataAsync().ContinueWith(async (pixels) => { await _bitmap.Dispatcher.InvokeAsync(() => { _bitmap.FromByteArray(pixels.Result); }); }); } }