-1

as you can read from the title i want to be able to draw some images on the screen, move them in some direction and video capture the movement with a good fps rate.

I want to specify that i do not want to record the desktop nor some portion of it but the content of the actual window in which the images are moving(so the window can also be minimized). Also if possible i want to be able to set a custom size for my view where everything will happen.

Where i should start from?

I have already tried with WPF but as the UI is single threaded i am not able to take a screenshot of the view while something is moving on it.

What library you would suggest me? Are there similar open-source projects i can learn from? Any suggestion i welcomed!

Drunk Cat
  • 483
  • 1
  • 4
  • 9

1 Answers1

1

Here's some code I recently wrote to do this, it cycles through a number of frames and renders a control (in this case, a Canvas) into PNGs:

private void Export(int frame)
{
    // force the control to update after any changes you've just made
    theCanvas.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);

    // render the control into a bitmap
    RenderTargetBitmap bitmap = new RenderTargetBitmap(1920, 1080, 96, 96, PixelFormats.Pbgra32);
    bitmap.Render(theCanvas);

    // save the bitmap out as a PNG
    using (var stream = File.Create($"Animation/Frame_{frame.ToString("D3")}.png"))
    {
        var encoder = new PngBitmapEncoder();
        encoder.Frames.Add(BitmapFrame.Create(bitmap));
        encoder.Save(stream);
    }
}

You can then use ffmpeg to pack those PNGs into the movie file format of your choice.

Mark Feldman
  • 15,731
  • 3
  • 31
  • 58
  • I have checked your code and it works but i'll keep the answer open since i hope in a more sophisticated and controllable solution. – Drunk Cat Nov 05 '19 at 20:08