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