So, I have a Winforms control that is an ElementHost of a WPF control. This WPF control houses several different UIElements that renders GIS data (vector and raster). What I'd like to do is record the user's activity and any animations (like vehicle position). None of the following methods work for me because they are either too slow or have limitations.
Method 1: DrawToBitmap
In previous iterations, the control was in pure Winforms. I could just call the Winforms DrawToBitmap method and get an image in about 10ms. But now that I'm using an ElementHost, getting an image in about 80ms. I have a feeling that behind the scenes, this method is using the RenderTargetBitmap method.
Method 2: RenderTargetBitmap
Alternatively, I tried using RenderTargetBitmap, passing in the canvas from the WPF control to create a bitmap image. But this also takes about 80ms to complete.
Method 3: System.Drawing CopyFromScreen
Doing a screen capture this way works. I can get images in about 35ms. But if a separate window gets in the way during recording or something of that matter, then the recording sees it too.
My Question
Is there a way to record a control that is faster than RenderTargetBitmap without the downside of CopyFromScreen? Is it possible to get in front of the RenderContext found in the OnRender of a control and create an image from that? Or maybe there is some other way that I'm not thinking of?