[英]How can I take a picture from screen?
I want to write a program that shows one PC's screen to the others... something like presentation systems. 我想编写一个程序,将一个PC的屏幕显示给其他人……类似于演示系统。 how can i take a picture from current screen?
如何在当前屏幕上拍照?
.NET exposes this functionality via the Screen ( System.Windows.Forms ) class. .NET通过Screen( System.Windows.Forms )类公开此功能。
// 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.