Ptr.Zero);//生成缩略图
OK=true;
myBitmap.Dispose();
}
catch
{
OK= false;
}
System.IO.MemoryStream ms = new System.IO.MemoryStream();
myThumbnail.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
return ms;
}
}
}
如何应用此类呢?还是贴代码:
1.新建一个aspx页面,放一个<img>标签
代码如下:
Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Ants.Tools.WebForm1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/uploadfile/201210/12/08203139200.jpg&width=120&height=90" alt="" />
</div>
<br />
<div style="border: 1px solid black; width:120px; height:90px; text-align:center; vertical-align:middle">
<img src=/uploadfile/201210/12/AE203141304.jpg&width=120&height=90" alt="" />
</div>
</div>
</form>
</body>
</html>
2.再建一个ashx文件
代码如下:
Code
using System.Web;
namespace Ants.Tools
{
public class Handler1 : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Image img = new Image();
img.Path = context.Request.QueryString["path"].ToString();
img.Width = context.Request.Q