日期:2011-09-22  浏览次数:20555 次

前台:
<HTML>
    <HEAD>
        <title>WebForm3</title>
            </HEAD>
    <body>
        <form id="Form1" method="post" runat="server">
             <INPUT id="loadFile" type="file" runat="server">
            <asp:Button id="Button1" runat="server" Text="Button"></asp:Button><BR>
            <asp:Image id="Image1" runat="server"></asp:Image></form>
    </body>
</HTML>

后台CS代码:
 1/**//// <summary>
 2        /// 生成缩略图
 3        /// </summary>
 4        /// <param name="fileName">原文件</param>
 5        /// <param name="width">宽度</param>
 6        /// <param name="height">高度</param>
 7        private void CreateThumbnailImage( string fileName,string smallPath,int width,int height )
 8        {   
 9            //版权信息
10            string strAdd = "www.wander.com";
11            //生成的缩略图的名字=年月日+文件大小(防止文件名相同)
12            string newFileName = smallPath;
13
14            System.Drawing.Image image,newImage;
15            //载入原图像
16            image = System.Drawing.Image.FromFile( Server.MapPath( fileName ) );
17            //回调
18            System.Drawing.Image.GetThumbnailImageAbort callb = new System.Drawing.Image.GetThumbnailImageAbort( callBack );
19            //生成缩略图
20            newImage = image.GetThumbnailImage( width,height,callb,new System.IntPtr() );
21           
22            AddInfo( newImage,strAdd,newFileName,16 );
23           
24            image.Dispose();
25            newImage.Dispose();
26
27            Image1.ImageUrl = newFileName;
28        }
29
30        /**//// <summary>
31        /// 添加版权信息
32        /// </summary>
33        /// <param name="image"></param>
34        /// <param name="strAdd"></param>
35        /// <param name="newFileName"></param>
36  &n