1 台の PC の画面を他の PC に表示するプログラムを作成したいと考えています... プレゼンテーション システムのようなものです。現在の画面から写真を撮るにはどうすればよいですか?
1 に答える
2
.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-30T03:10:10.930 に答える