-2

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

请帮帮我!

4

2 回答 2

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);
于 2012-12-06T07:44:41.973 回答
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/

于 2012-12-06T07:46:06.263 回答