Capture screen using C# and .Net 2.0
Remember old BitBlt API, for capturing screens? Here is the solution from Microsoft on .Net framework 2.0. CopyFromScreen Method – Performs a bit-block transfer of color data from the screen to the drawing surface of the Graphics.
Rectangle region = new Rectangle(0, 0, SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
using (Bitmap bitmap = new Bitmap(region.Width, region.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
using (Graphics bitmapGraphics = Graphics.FromImage(bitmap))
{
bitmapGraphics.CopyFromScreen(region.Left, region.Top, 0, 0, region.Size);
Clipboard.SetImage(bitmap);
}
It only works with .Net 2.0 and more.
I developed an Application, which hosted in Codeplex, called captureit., which is using this code for capturing desktop.
MSDN : http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.copyfromscreen.aspx
Windows Forms lifecycle
Win forms lifecycle.
- Constructor
- Load
- Layout
- Activated
- Paint
- Closing
- Closed
- Deactivate
- Dispose
And here is the life cycle of Controls
- Enter
- Gotfocus
- Leave
- Validating
- Validated
- Lostfocus
Transfer Image Files using .Net remoting
Here is the sequence for downloading an Image from remoting server to client.
- Save image into Memorystream.
- Extract byte array
- Transfer byte array
- Recreate image object from byte array.
Create a class which inherits MarshalByRefObject, and create a public method, which returns a byte array.
In the client side, invoke this method and convert the byte array to image.
About .Net remoting :
http://msdn2.microsoft.com/en-us/webservices/aa740645.aspx
Converting byte array to Image and Image to byte array :
http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=799