本文实例展示了asp.net截屏功能实现截取web页面的方法,代码简洁易懂,分享给大家供大家参考。
具体实现代码如下:
using System.Drawing; //打开该页面System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://localhost:56/Spacxxe.html");System.Threading.Thread.Sleep(3000);//截屏//创建并设置画布大小System.Drawing.Image templateImage = new System.Drawing.Bitmap(1040, 700);System.Drawing.Graphics templateG = System.Drawing.Graphics.FromImage(templateImage);//new Point(200, 100)位于源(屏幕)左上角的x,y坐标//new Point(0, 0)图片位于画布左上角的x,y坐标//new Size(1440, 900)所截屏幕的大小templateG.CopyFromScreen(new Point(200, 100), new Point(0, 0), new Size(1000, 900), CopyPixelOperation.MergeCopy);//关闭ieSystem.Diagnostics.Process[] pro = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");foreach (System.Diagnostics.Process ps in pro){ ps.Kill();}//保存templateImage.Save(@"E:\TEST\" + imgname + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);希望本文所述实例对大家能有所帮助。