c# - 如何抓取图像并将其保存在文件夹中[c# windows应用程序]

标签 c# windows image screen-grab

我正在使用 c# 创建一个 Windows 应用程序。我有一个按钮应该捕获图像(整个桌面屏幕)并将其保存在文件夹中。此外,我需要显示图像的预览。

最佳答案

Graphics.CopyFromScreen Method

示例代码:

Bitmap bmp = new Bitmap(Screen.PrimaryScreen.Bounds.Size.Width, Screen.PrimaryScreen.Bounds.Size.Height);
Graphics g = Graphics.FromImage(bmp);
g.CopyFromScreen(0, 0, 0, 0, Screen.PrimaryScreen.Bounds.Size);
g.Save();
bmp.Save("D:\\file.jpg", ImageFormat.Bmp);

至于显示预览。 IMO 自己编写并不难。

关于c# - 如何抓取图像并将其保存在文件夹中[c# windows应用程序],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6572457/

相关文章:

c# - 如何从已转换为对象的匿名类型中获取数据?

C# 套接字模型 View 控件

image - 为什么图像不能完全从逻辑图像转换回来

perl - 如何在 Perl 中验证图像文件?

image - 在不增加图像大小的情况下提高 dvipng 的图像质量?

c# - 使 div 看起来像 ListBox

c# - 将参数传递给 SharePoint 计时器作业

c# - Windows 注册表中的 ProductName,是否针对不同语言进行了本地化?

windows - 如何以编程方式解锁窗口

android - Nexus 7 (2013) 和 Win 7 64 - 尽管检查了许多论坛和在线资源,但无法安装 USB 驱动程序