I have seen StackOverflow answers using the following code to capture monitor output using the System.Drawing namespace:
using var bitmap = new Bitmap(1920, 1080);
using (var g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(0, 0, 0, 0,
bitmap.Size, CopyPixelOperation.SourceCopy);
}
bitmap.Save("filename.jpg", ImageFormat.Jpeg);
However CopyFromScreen is for a single monitor - I need to capture all monitors, and have seen other answers using the System.Windows.Forms namespace and the Screen.AllScreens method.
My questions are please:
Is there any native WPF/WinUI multi-platform way of capturing all monitors?
Or would one instead need to make a DI container interface and dynamically configure the OS specific
IScreenCaptureimplementation on application start - the Windows one I could work out, what would the Mac .NET 6 screen capture interface look like?