zoukankan      html  css  js  c++  java
  • Web截取网页图片

    using System;
    using System.Collections;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Drawing;

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string PhotoName = Guid.NewGuid().ToString();
            //打开该页面
            System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://www.baidu.com");

            System.Threading.Thread.Sleep(3000);
            //截屏

            //创建并设置画布大小
            System.Drawing.Image templateImage = new System.Drawing.Bitmap(1040,800);
            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, 150), new Point(0, 0), new Size(1040, 800), CopyPixelOperation.MergeCopy);

            //关闭ie
            System.Diagnostics.Process[] pro = System.Diagnostics.Process.GetProcessesByName("IEXPLORE");
            foreach (System.Diagnostics.Process ps in pro)
            {
                ps.Kill();
            }

            //存
            //templateImage.Save(@"E:\TEST\" + photoname + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            templateImage.Save(Server.MapPath("SnapPic/" + PhotoName + ".jpg"), System.Drawing.Imaging.ImageFormat.Png);//保存截图到项目SnapPic目录下

        }
    }

    Any fool can write code that a computer can understand. Good programmers write code that humans can understand. –Martin Fowler
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。
  • 相关阅读:
    TreeSet类的排序问题
    TreeSet()详解
    css中vertical-align垂直居中的认识
    CSS3 float深入理解浮动资料整理
    层叠顺序与层叠上下文
    jquery.zclip轻量级复制失效问题
    文章转载利用border、transparent实现微风
    转载利用线性渐变实现晴天、多云特效
    转载利用伪元素单个颜色实现 hover 和 active 时的明暗变化效果
    MUI-最接近原生App体验的前端框架
  • 原文地址:https://www.cnblogs.com/gerryge/p/2241163.html
Copyright © 2011-2022 走看看