免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
C#實現(xiàn)網(wǎng)頁截圖功能
  1. //需要添加System.Drawing及System.Windows.Forms引用   
  2. using System;   
  3. using System.Drawing;   
  4. using System.Drawing.Drawing2D;   
  5. using System.Drawing.Imaging;   
  6. using System.Windows.Forms;   
  7.   
  8.   
  9. namespace 網(wǎng)頁截圖   
  10. {   
  11.     class Program   
  12.     {   
  13.         [STAThread]   
  14.         static void Main(string[] args)   
  15.         {   
  16.             string url = "http://www.yongfa365.com/";   
  17.             MyLib.GetImage thumb = new MyLib.GetImage(url, 1024, 4000, 1024, 4000);   
  18.             System.Drawing.Bitmap x = thumb.GetBitmap();   
  19.             string FileName = DateTime.Now.ToString("yyyyMMddhhmmss");   
  20.   
  21.             x.Save(@"C:\" + FileName + ".jpg");   
  22.             Console.WriteLine("成功");   
  23.             Console.ReadKey();   
  24.         }   
  25.     }   
  26. }   
  27.   
  28.   
  29.   
  30.   
  31.   
  32. namespace MyLib   
  33. {   
  34.     public class GetImage   
  35.     {   
  36.         private int S_Height;   
  37.         private int S_Width;   
  38.         private int F_Height;   
  39.         private int F_Width;   
  40.         private string MyURL;   
  41.   
  42.         public int ScreenHeight   
  43.         {   
  44.             get { return S_Height; }   
  45.             set { S_Height = value; }   
  46.         }   
  47.   
  48.         public int ScreenWidth   
  49.         {   
  50.             get { return S_Width; }   
  51.             set { S_Width = value; }   
  52.         }   
  53.   
  54.         public int ImageHeight   
  55.         {   
  56.             get { return F_Height; }   
  57.             set { F_Height = value; }   
  58.         }   
  59.   
  60.         public int ImageWidth   
  61.         {   
  62.             get { return F_Width; }   
  63.             set { F_Width = value; }   
  64.         }   
  65.   
  66.         public string WebSite   
  67.         {   
  68.             get { return MyURL; }   
  69.             set { MyURL = value; }   
  70.         }   
  71.   
  72.         public GetImage(string WebSite, int ScreenWidth, int ScreenHeight, int ImageWidth, int ImageHeight)   
  73.         {   
  74.             this.WebSite = WebSite;   
  75.             this.ScreenWidth = ScreenWidth;   
  76.             this.ScreenHeight = ScreenHeight;   
  77.             this.ImageHeight = ImageHeight;   
  78.             this.ImageWidth = ImageWidth;   
  79.         }   
  80.   
  81.         public Bitmap GetBitmap()   
  82.         {   
  83.             WebPageBitmap Shot = new WebPageBitmap(this.WebSite, this.ScreenWidth, this.ScreenHeight);   
  84.             Shot.GetIt();   
  85.             Bitmap Pic = Shot.DrawBitmap(this.ImageHeight, this.ImageWidth);   
  86.             return Pic;   
  87.         }   
  88.     }   
  89.   
  90.     class WebPageBitmap   
  91.     {   
  92.         WebBrowser MyBrowser;   
  93.         string URL;   
  94.         int Height;   
  95.         int Width;   
  96.   
  97.         public WebPageBitmap(string url, int width, int height)   
  98.         {   
  99.             this.Height = height;   
  100.             this.Width = width;   
  101.             this.URL = url;   
  102.             MyBrowser = new WebBrowser();   
  103.             MyBrowser.ScrollBarsEnabled = false;   
  104.             MyBrowser.Size = new Size(this.Width, this.Height);   
  105.         }   
  106.   
  107.         public void GetIt()   
  108.         {   
  109.             MyBrowser.Navigate(this.URL);   
  110.             while (MyBrowser.ReadyState != WebBrowserReadyState.Complete)   
  111.             {   
  112.                 Application.DoEvents();   
  113.             }   
  114.         }   
  115.   
  116.         public Bitmap DrawBitmap(int theight, int twidth)   
  117.         {   
  118.             Bitmap myBitmap = new Bitmap(Width, Height);   
  119.             Rectangle DrawRect = new Rectangle(0, 0, Width, Height);   
  120.             MyBrowser.DrawToBitmap(myBitmap, DrawRect);   
  121.             System.Drawing.Image imgOutput = myBitmap;   
  122.             System.Drawing.Image oThumbNail = new Bitmap(twidth, theight, imgOutput.PixelFormat);   
  123.             Graphics g = Graphics.FromImage(oThumbNail);   
  124.             g.CompositingQuality = CompositingQuality.HighSpeed;   
  125.             g.SmoothingMode = SmoothingMode.HighSpeed;   
  126.             g.InterpolationMode = InterpolationMode.HighQualityBilinear;   
  127.             Rectangle oRectangle = new Rectangle(0, 0, twidth, theight);   
  128.             g.DrawImage(imgOutput, oRectangle);   
  129.             try  
  130.             {   
  131.                 return (Bitmap)oThumbNail;   
  132.             }   
  133.             catch (Exception ex)   
  134.             {   
  135.                 return null;   
  136.             }   
  137.             finally  
  138.             {   
  139.                 imgOutput.Dispose();   
  140.                 imgOutput = null;   
  141.                 MyBrowser.Dispose();   
  142.                 MyBrowser = null;   
  143.             }   
  144.         }   
  145.     }   
  146.   
  147. }  

 

 


引用本頁地址:http://www.yongfa365.com/item/CShiXianWangYeJieTuGongNeng.html
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
ASP.NET根據(jù)URL生成網(wǎng)頁縮略圖示例程序(C#語言)
ASP.NET驗證碼
asp.net core2.0 驗證碼
根據(jù)文本內(nèi)容創(chuàng)建圖片并返回圖片路徑
c#圖像處理入門(
生成規(guī)定大小的圖片(縮略圖生成) - 懶人一個。。。 - 博客園
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服