I am looking to capture a screenshot using .NET core. I know that this is trivial using the .NET framework but is this possible using .NET core? I have searched but I can't find any answers anywhere.
System.Drawing.Common
is available cross platform in .NET Core now allowing you to take screenshots of windows/your desktop. Here is an example
EDIT
An example capturing a screenshot:
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With