asp.net怎么读取网页生成缩略图 例如: <img src="smailImage.aspx">smailImage.aspx 输出展示一个缩略图 怎么弄呢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 本帖最后由 net_lover 于 2012-04-05 14:06:28 编辑 或者显示指定文件的缩略图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();} 如果是指定的页面 怎么弄呢。不是文件 例如:http://192.168.3.14/a.aspx 或者 http:www.baidu.com 这样的url 呢 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 已经写好了。可惜我页面用的jquery easy ui 布局 ajax 擦。 截出来的图片都是正在加载中.. 求 上传文件 3D 图片加水印的方法 aspx页面如何直接打印 csdn 小白问题 求TreeView多级绑定问题 vs2008 自带ajax extend能实现这个功能吗? 如何将 Visual Studio 2005 中的默认验证改为“Internet Explorer 6.0”。 ASP.NET用户身份认证,授权,在会话周期内保存状态。 生成的静态网页内容如何分段 asp.net中的身份认证 asp.net项目里如何实现指纹识别登陆系统 急急急急急急急急急急急急急急急急!!!img添加汉字
{
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();
}
http://www.websitesscreenshot.com/
1,抓取到需要的网页
2.通过GDI+做成图片