Bitmap bitmap = new Bitmap(990, 540);
Graphics graphics = Graphics.FromImage(bitmap as System.Drawing.Image);
graphics.CopyFromScreen(5, 160, 0, 0, bitmap.Size);
bitmap.Save(@"c:\\" + ddlSession.Text.ToString().Trim() + "DailySchedule.bmp", ImageFormat.Bmp);
ShowEditLink(true);
lblUpdate.Text = "This image is saved";
The above code is working in local machine, but when i execute on the server error as follows
System.ComponentModel.Win32Exception: The handle is invalid
The below error shows in following line as follows
graphics.CopyFromScreen(5, 160, 0, 0, bitmap.Size);
please help me. what is the problem in my code.
Regards,
Rao.
RobbinsonPosted Oct 21, 2013, 9:29 AM
I think, there is no screen on the server. it was working on your local machine as server was your client screen. if you want to capture client screen means webpage, it would be possible using javascript code.
one of the library, i came across for same requirement is html2Canvas. For more details,
http://html2canvas.hertzen.com/#/screenshots.html
Another option may be using the GDI32. The below article may help you to understand how GDI+ can be used.
http://www.csharphelp.com/2006/11/capturing-the-screen-image-using-c/
Hope, this would help you out.
Please don't forget to mark as answer if this post helps you.