0
我想编写一个程序,向其他人展示一台PC的屏幕......像展示系统。我如何从当前屏幕拍照?如何从屏幕上拍照?
我想编写一个程序,向其他人展示一台PC的屏幕......像展示系统。我如何从当前屏幕拍照?如何从屏幕上拍照?
.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
谢谢你的帮助......还有什么其他方法可以让它更快吗?因为我的项目对屏幕的复制速度应该很慢...... – 2010-09-30 03:21:46
GDI +方法并不是世界上任何度量标准中最快的。你打算怎么做? – Michael 2010-09-30 14:21:23