通过C#命令捕获屏幕

时间:2012-12-06 07:40:17

标签: c#

我需要创建一个C#应用程序,它允许我捕获屏幕并保存图像文件。

请帮助我!

2 个答案:

答案 0 :(得分:1)

            Point curPos = new Point(Cursor.Position.X, Cursor.Position.Y);
            Size curSize = new Size();
            curSize.Height = Cursor.Current.Size.Height; curSize.Width = Cursor.Current.Size.Width;
            System.Threading.Thread.Sleep(250);
            Rectangle r1 = Screen.GetBounds(Screen.GetBounds(Point.Empty));
            Bitmap b1 = new Bitmap(r1.Width, r1.Height);
            Graphics g1 = Graphics.FromImage(b1);
            g1.CopyFromScreen(Point.Empty, Point.Empty, r1.Size);
            Rectangle r2 = new Rectangle(curPos, curSize);
            Cursors.Default.Draw(g1, r2);
            b1.Save(@"C:\file1.bmp", ImageFormat.Bmp);

答案 1 :(得分:1)

ScreenCapture sc = new ScreenCapture();
// capture entire screen, and save it to a file
Image img = sc.CaptureScreen();
// display image in a Picture control named imageDisplay
this.imageDisplay.Image = img;
// capture this window, and save it
sc.CaptureWindowToFile(this.Handle,"C:\\temp2.gif",ImageFormat.Gif);

完整项目来自:http://www.developerfusion.com/code/4630/capture-a-screen-shot/

相关问题