C# 如何从屏幕上拍照?

C# 如何从屏幕上拍照?,c#,screen,screen-capture,C#,Screen,Screen Capture,我想写一个程序,显示一台电脑的屏幕给其他人。。。类似于演示系统。如何从当前屏幕拍照?.NET通过screen(System.Windows.Forms)类公开此功能 谢谢你的帮助。。。还有没有别的办法让它更快?因为从屏幕复制对我的项目来说应该很慢…GDI+方法并不是世界上最快的。你打算用这个做什么? // the surface that we are focusing upon Rectangle rect = new Rectangle(); // captu

我想写一个程序,显示一台电脑的屏幕给其他人。。。类似于演示系统。如何从当前屏幕拍照?

.NET通过screen(System.Windows.Forms)类公开此功能


谢谢你的帮助。。。还有没有别的办法让它更快?因为从屏幕复制对我的项目来说应该很慢…GDI+方法并不是世界上最快的。你打算用这个做什么?
     // the surface that we are focusing upon
     Rectangle rect = new Rectangle();

     // capture all screens in Windows
     foreach (Screen screen in Screen.AllScreens)
     {
        // increase the Rectangle to accommodate the bounds of all screens
        rect = Rectangle.Union(rect, screen.Bounds);
     }

     // create a new image that will store the capture
     Bitmap bitmap = new Bitmap(rect.Width, rect.Height, PixelFormat.Format32bppArgb);

     using (Graphics g = Graphics.FromImage(bitmap))
     {
        // use GDI+ to copy the contents of the screen into the bitmap
        g.CopyFromScreen(rect.X, rect.Y, 0, 0, rect.Size, CopyPixelOperation.SourceCopy);
     }

     // bitmap now has the screen capture