如何在多个操作系统的c#中以编程方式制作屏幕截图?
我有一个在多个系统上运行的应用程序。 Mac Linux和Windows 7。
答案 0 :(得分:1)
for Windows,
ScreenCapture sc = new ScreenCapture();
Image img = sc.CaptureScreen();
this.imageDisplay.Image = img;
sc.CaptureWindowToFile(this.Handle,"D:\\ScreenShot1.png",ImageFormat.png);
按照实施链接
http://www.developerfusion.com/code/4630/capture-a-screen-shot/
答案 1 :(得分:0)
我从来没有试过这个我的自我,但这是我在网络问题中找到的。
ScreenCapture sc = new ScreenCapture();
// capture the screen and stores it in a image
Image img = sc.CaptureScreen();
以下是我从中获取信息的问题 Capture screenshot of active window?
这是对他们得到答案的网站的引用 http://www.developerfusion.com/code/4630/capture-a-screen-shot/
希望这有帮助。
编辑:这是我找到的另一种方式
private Bitmap Screenshot()
{
//Create a bitmap with the same dimensions like the screen
Bitmap screen = new Bitmap(SystemInformation.VirtualScreen.Width,
SystemInformation.VirtualScreen.Height);
//Create graphics object from bitmap
Graphics g = Graphics.FromImage(screen);
//Paint the screen on the bitmap
g.CopyFromScreen(SystemInformation.VirtualScreen.X,
SystemInformation.VirtualScreen.Y,
0, 0, screen.Size);
g.Dispose();
//return bitmap object / screenshot
return screen;
}
此处的参考资料http://en.code-bude.net/2012/12/27/how-to-take-a-screenshot-in-csharp/