public void UpdateImage(TIS.Imaging.IFrameQueueBuffer buffer) { int bufferWidth = buffer.FrameType.Width; int bufferHeight = buffer.FrameType.Height; PixelFormat bufferFormat = PixelFormatFromFrameType(buffer.FrameType); display.Dispatcher.Invoke( (Action)(() => { if ((_source == null) || (_source.PixelWidth != bufferWidth) || (_source.PixelHeight != bufferHeight) || (_source.Format != bufferFormat)) { _source = CreateBackBuffer(bufferWidth, bufferHeight, bufferFormat); CopyImageBufferToWritableBitmap(buffer, _source); display.Source = _source; } else { CopyImageBufferToWritableBitmap(buffer, _source); } _overlayAdorner.InvalidateVisual(); IsSourceBottomUp = buffer.FrameType.IsBottomUp; UpdateFlip(); }) ); }
private void CopyImageBufferToWritableBitmap(TIS.Imaging.IFrameQueueBuffer buffer, WriteableBitmap wb) { var rect = new Int32Rect(0, 0, buffer.FrameType.Width, buffer.FrameType.Height); wb.WritePixels(rect, buffer.GetIntPtr(), buffer.FrameType.BufferSize, buffer.FrameType.BytesPerLine); }