forum

Home / DeveloperSection / Forums / How to capture screenshot in asp.net

How to capture screenshot in asp.net

Vani V 5098 13-Dec-2010

Hi All,

 I am trying to take a Screen shot of the client Screen[they are allowed to draw a diagram,when they click save ,it should get saved as Image in database.

Also the user should be able to see it again] . After searching for 2 week ,i implemented the below code in [windows xp,asp.net,C#,SQL]

develpment machine and it works fine. When i deployed the app in Server ,then the problem started.When the Save button is clicked it gave

  System.ComponentModel.Win32Exception: The handle is invalid
[Win32Exception (0x80004005): The handle is invalid]

System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) +542 Default3.ThreadMethod() +225


Below is the code


Rectangle bounds = new Rectangle(620, 370, Convert.ToInt32(Panel1.Width.Value) - 20, Convert.ToInt32(Panel1.Height.Value) - 10); using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(new Point(bounds.Left, bounds.Top), Point.Empty, bounds.Size); } bitmap.Save(Server.MapPath("~") + "\\ScreenShot\\" + Request.QueryString["TrafficID"].ToString() + ".JPEG", ImageFormat.Jpeg); } Thanks,

c# c# 
Updated on 14-Dec-2010

Can you answer this question?


Answer

1 Answers

Liked By