I want to write a program that shows one PC's screen to the others... something like presentation systems. how can i take a picture from current screen?
+1
A:
.NET exposes this functionality via the Screen (System.Windows.Forms) class.
// 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
Michael
2010-09-30 03:10:10
Thank you for your help... And is there any other way to make it faster? coz copying from screen should be slow for my project...
Dr TJ
2010-09-30 03:21:46
GDI+ methods are not the fastest in the world by any metric. What are you intending to do with this?
Michael
2010-09-30 14:21:23