您目前尚未登陆,请选择【登陆】或【注册
首页->功能源码->Asp.net实现网站截图(WebSnap)功能源码>>Snap/GetImage.cs>>代码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:Asp.net实现网站截图(WebSnap)功能源码


当前文件路径:WebSnap/Snap/GetImage.cs 文件类型
普通视图
		            
1/* 2 * 修改者:吴鹏(AlphaWu) 3 * Blog:Http://AlphaWu.CoM 4 * 获取网站缩略图代码 5 * 2006 圣诞节 6 * C#代码根据该页面“http://www.codeproject.com/useritems/website_screenshot.asp 7 * VB.Net代码修改而来 8 * 欢迎修改和传播 9 * 最好能保留该信息^_^ 10 * 也欢迎大家访问我的博客 11 * Http://AlphaWu.Cnblogs.CoM 12 * 13 * Http://AlphaWu.CoM 14 * 15 * 16 */ 17using System; 18using System.Drawing; 19using System.Drawing.Imaging; 20using System.Windows.Forms; 21 22namespace Snap 23{ 24 public class GetImage 25 { 26 int S_Height; 27 int S_Width; 28 int F_Height; 29 int F_Width; 30 string MyURL; 31 32 public int ScreenHeight 33 { 34 get 35 { 36 return S_Height; 37 } 38 set 39 { 40 S_Height = value; 41 } 42 } 43 44 public int ScreenWidth 45 { 46 get 47 { 48 return S_Width; 49 } 50 set 51 { 52 S_Width = value; 53 } 54 } 55 56 public int ImageHeight 57 { 58 get 59 { 60 return F_Height; 61 } 62 set 63 { 64 F_Height = value; 65 } 66 } 67 68 public int ImageWidth 69 { 70 get 71 { 72 return F_Width; 73 } 74 set 75 { 76 F_Width = value; 77 } 78 } 79 80 public string WebSite 81 { 82 get 83 { 84 return MyURL; 85 } 86 set 87 { 88 MyURL = value; 89 } 90 } 91 92 public GetImage(string WebSite, int ScreenWidth, int ScreenHeight, int ImageWidth, int ImageHeight) 93 { 94 this.WebSite = WebSite; 95 this.ScreenHeight = ScreenHeight; 96 this.ScreenWidth = ScreenWidth; 97 this.ImageHeight = ImageHeight; 98 this.ImageWidth = ImageWidth; 99 } 100 101 public Bitmap GetBitmap() 102 { 103 WebPageBitmap Shot = new WebPageBitmap(this.WebSite, this.ScreenWidth, this.ScreenHeight); 104 105 Shot.GetIt(); 106 Bitmap Pic = Shot.DrawBitmap(this.ImageHeight, this.ImageWidth); 107 return Pic; 108 } 109 } 110 111 public class WebPageBitmap 112 { 113 WebBrowser MyBrowser; 114 string URL; 115 int Height; 116 int Width; 117 118 public WebPageBitmap(string url, int width, int height) 119 { 120 this.URL = url; 121 this.Width = width; 122 this.Height = height; 123 MyBrowser = new WebBrowser(); 124 MyBrowser.ScrollBarsEnabled = false; 125 MyBrowser.Size = new Size(this.Width, this.Height); 126 } 127 128 public void GetIt() 129 { 130 MyBrowser.Navigate(this.URL); 131 while (MyBrowser.ReadyState != WebBrowserReadyState.Complete) 132 { 133 Application.DoEvents(); 134 } 135 } 136 137 public Bitmap DrawBitmap(int theight, int twidth) 138 { 139 Bitmap myBitmap = new Bitmap(this.Width, this.Height); 140 Rectangle DrawRect = new Rectangle(0, 0, this.Width, this.Height); 141 MyBrowser.DrawToBitmap(myBitmap, DrawRect); 142 System.Drawing.Image imgOutput = myBitmap; 143 System.Drawing.Bitmap oThumbNail = new Bitmap(twidth, theight, imgOutput.PixelFormat); 144 Graphics g = Graphics.FromImage(oThumbNail); 145 146 g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed; 147 g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed; 148 g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; 149 150 Rectangle oRectangle = new Rectangle(0, 0, twidth, theight); 151 g.DrawImage(imgOutput, oRectangle); 152 153 try 154 { 155 return oThumbNail; 156 } 157 catch 158 { 159 return null; 160 } 161 finally 162 { 163 imgOutput.Dispose(); 164 imgOutput = null; 165 MyBrowser.Dispose(); 166 MyBrowser = null; 167 } 168 169 } 170 } 171} 172
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Asp.net实现网站截图(WebSnap)功能源码

- 简单四则运算验证码(C#)源码

- 某大学车辆管理系统商用源码

- Asp.net2.0应用之RSS在线阅读..

- AfritxiaWebTest2.0源码

- 小付文件上传下载系统

- FCKeditor2.4.2编辑器 For A..

- 最简单三层登陆入门源码

- 某大学学生管理系统(毕业设..

51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号