首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

asp.net如何读取网页生成缩略图

2012-08-03 
asp.net怎么读取网页生成缩略图例如:HTML code img srcsmailImage.aspxC# codesmailImage.aspx 输出

asp.net怎么读取网页生成缩略图
例如: 

HTML code
 <img src="smailImage.aspx">

C# code
smailImage.aspx 输出

展示一个缩略图 怎么弄呢

[解决办法]
smailImage.aspx里面


C# code
protected void Page_Load(object sender, EventArgs e){  Response.ClearContent();  Response.ContentType = "images/jpeg";  Response.BinaryWrite(System.IO.File.ReadAllBytes(Server.MapPath("~/aaaa.jpg")));  Response.End();}
[解决办法]
或者显示指定文件的缩略图

C# code
protected void Page_Load(object sender, EventArgs e){  Response.ClearContent();  Response.ContentType = "images/jpg";  String file = Server.MapPath("~/aaaa.jpg"); //显示aaaa.jpg的缩略图  System.Drawing.Image image = System.Drawing.Image.FromStream(new System.IO.MemoryStream(System.IO.File.ReadAllBytes(file)));  int newWidth = 100, newHeight = 100;  if ((decimal)image.Width / image.Height > (decimal)newWidth / newHeight)  {    newHeight = Convert.ToInt32((decimal)image.Height * newWidth / image.Width);  }  else if ((decimal)image.Width / image.Height < (decimal)newWidth / newHeight)  {    newWidth = Convert.ToInt32((decimal)image.Width * newHeight / image.Height);  }  System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(newWidth, newHeight);  System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp);  g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;  g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;  g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;  System.Drawing.Rectangle rectDestination = new System.Drawing.Rectangle(0, 0, newWidth, newHeight);  g.DrawImage(image, rectDestination, 0, 0, image.Width, image.Height, System.Drawing.GraphicsUnit.Pixel);  bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);  bmp.Dispose();  image.Dispose();  Response.End();}
[解决办法]
探讨

或者显示指定文件的缩略图

C# code
protected void Page_Load(object sender, EventArgs e)
{
Response.ClearContent();
Response.ContentType = "images/jpg";
String file = Server.MapPath("~/aaaa.jpg"); //显示aaa……

[解决办法]
http://hi.baidu.com/zhenghanzheng/blog/item/7e0ac7640fa27af7f63654bf.html
[解决办法]
你先找一个把网页转成图片的程序,这种程序一般都是收费的,免费的好用的很难找


[解决办法]
比如
http://www.websitesscreenshot.com/


[解决办法]
给个思路,lz试下:
1,抓取到需要的网页
2.通过GDI+做成图片

[解决办法]
http://download.csdn.net/detail/anzhiqiang_touzi/1069856

热点排行