gho*_*oul 3 .net c# console-application
我正在尝试使用 .NET Framework 编写一个控制台应用程序。我想截图我的屏幕。我已经使用过其他答案,如下所示:
问题是这并不能捕获我的整个屏幕。底部和右侧大约缺失 1/5。
如何使用 C# .NET Framework 捕获整个屏幕?
使用虚拟屏幕:
int screenLeft = SystemInformation.VirtualScreen.Left;
int screenTop = SystemInformation.VirtualScreen.Top;
int screenWidth = SystemInformation.VirtualScreen.Width;
int screenHeight = SystemInformation.VirtualScreen.Height;
// Create a bitmap of the appropriate size to receive the full-screen screenshot.
using (Bitmap bitmap = new Bitmap(screenWidth, screenHeight))
{
// Draw the screenshot into our bitmap.
using (Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(screenLeft, screenTop, 0, 0, bitmap.Size);
}
//Save the screenshot as a Jpg image
var uniqueFileName = "C:\\temp\\a.Jpg";
try
{
bitmap.Save(uniqueFileName, ImageFormat.Jpeg);
}
catch (Exception ex) {
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8418 次 |
| 最近记录: |