DotNetCore在Windows中捕获屏幕截图 [英] DotNetCore Capture A Screenshot in Windows
本文介绍了DotNetCore在Windows中捕获屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找使用.NET core的屏幕截图.我知道使用.NET框架是微不足道的,但是使用.NET核心可能吗?我已经搜索过,但是在任何地方都找不到答案.
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
在.NET Core中可以跨平台使用,现在允许您截取Windows/桌面的屏幕截图.这里是一个例子
System.Drawing.Common
is available cross platform in .NET Core now allowing you to take screenshots of windows/your desktop. Here is an example
编辑
捕获屏幕截图的示例:
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);
这篇关于DotNetCore在Windows中捕获屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文