c# winform 调用系统函数截图 非dll
之前用的是申请dll截图
后来用的ffmpeg方案,但是这个打包ffmpeg方案太大了。
于是我就搜了下。csdn这个真的是坑,都是dll方案
c#从3.5到4.8都支持的函数
示例代码
Rectangle bounds = Screen.PrimaryScreen.WorkingArea;
Console.WriteLine(bounds.Width);
Console.WriteLine(bounds.Height);
using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(new Point(0,0), Point.Empty, bounds.Size);
bitmap.Save("D://test.jpg", ImageFormat.Jpeg);
}
比之前的好用多了