﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-DotWind CMS-最新评论</title><link>http://www.cnblogs.com/yaoo/CommentsRSS.aspx</link><description /><language>zh-cn</language><pubDate>Wed, 13 Jul 2011 05:13:34 GMT</pubDate><lastBuildDate>Wed, 13 Jul 2011 05:13:34 GMT</lastBuildDate><generator>cnblogs</generator><item><title>re: 使用FileUpload控件上传图片并自动生成缩略图、带文字和图片的水印图</title><link>http://www.cnblogs.com/yaoo/archive/2009/04/21/1136358.html#1508216</link><dc:creator>ddd</dc:creator><author>ddd</author><pubDate>Mon, 20 Apr 2009 16:03:11 GMT</pubDate><guid>http://www.cnblogs.com/yaoo/archive/2009/04/21/1136358.html#1508216</guid><description><![CDATA[FileInfo file = new FileInfo(name);<br/>怎么来的？？<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/yaoo/" target="_blank">ddd</a> 2009-04-21 00:03 <a href="http://www.cnblogs.com/yaoo/archive/2009/04/21/1136358.html#1508216#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 使用FileUpload控件上传图片并自动生成缩略图、带文字和图片的水印图</title><link>http://www.cnblogs.com/yaoo/archive/2009/04/21/1136358.html#1508215</link><dc:creator>ddd</dc:creator><author>ddd</author><pubDate>Mon, 20 Apr 2009 16:02:51 GMT</pubDate><guid>http://www.cnblogs.com/yaoo/archive/2009/04/21/1136358.html#1508215</guid><description><![CDATA[FileInfo file = new FileInfo(name);<br/><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/yaoo/" target="_blank">ddd</a> 2009-04-21 00:02 <a href="http://www.cnblogs.com/yaoo/archive/2009/04/21/1136358.html#1508215#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 使用FileUpload控件上传图片并自动生成缩略图、带文字和图片的水印图</title><link>http://www.cnblogs.com/yaoo/archive/2008/12/15/1136358.html#1402409</link><dc:creator>alane</dc:creator><author>alane</author><pubDate>Mon, 15 Dec 2008 03:11:22 GMT</pubDate><guid>http://www.cnblogs.com/yaoo/archive/2008/12/15/1136358.html#1402409</guid><description><![CDATA[十分感谢！这个程序很不错！呵呵！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/yaoo/" target="_blank">alane</a> 2008-12-15 11:11 <a href="http://www.cnblogs.com/yaoo/archive/2008/12/15/1136358.html#1402409#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: DropDownList实现无限级分类 </title><link>http://www.cnblogs.com/yaoo/archive/2008/11/26/1191967.html#1382265</link><dc:creator>VisualStudio</dc:creator><author>VisualStudio</author><pubDate>Wed, 26 Nov 2008 03:02:30 GMT</pubDate><guid>http://www.cnblogs.com/yaoo/archive/2008/11/26/1191967.html#1382265</guid><description><![CDATA[正好要用……找找感觉！<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/yaoo/" target="_blank">VisualStudio</a> 2008-11-26 11:02 <a href="http://www.cnblogs.com/yaoo/archive/2008/11/26/1191967.html#1382265#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: ASP.NET正则表达式集合</title><link>http://www.cnblogs.com/yaoo/archive/2008/10/26/1319870.html#1351727</link><dc:creator>JimLiu</dc:creator><author>JimLiu</author><pubDate>Sun, 26 Oct 2008 09:18:28 GMT</pubDate><guid>http://www.cnblogs.com/yaoo/archive/2008/10/26/1319870.html#1351727</guid><description><![CDATA[第二个是不是可以写成<br/>^[0-9]+$<br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/yaoo/" target="_blank">JimLiu</a> 2008-10-26 17:18 <a href="http://www.cnblogs.com/yaoo/archive/2008/10/26/1319870.html#1351727#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>re: 使用FileUpload控件上传图片并自动生成缩略图、带文字和图片的水印图</title><link>http://www.cnblogs.com/yaoo/archive/2008/04/03/1136358.html#1136930</link><dc:creator>liong</dc:creator><author>liong</author><pubDate>Thu, 03 Apr 2008 15:25:00 GMT</pubDate><guid>http://www.cnblogs.com/yaoo/archive/2008/04/03/1136358.html#1136930</guid><description><![CDATA[<br>public partial class _Default : System.Web.UI.Page <br>{<br>    protected void Page_Load(object sender, EventArgs e)<br>    {<br>    }<br><br>    protected void Button1_Click(object sender, EventArgs e)<br>    {<br>        if (FileUpload1.HasFile)<br>        {<br>            string fileContentType = FileUpload1.PostedFile.ContentType;<br>            if (fileContentType == &quot;image/bmp&quot; || fileContentType == &quot;image/gif&quot; || fileContentType == &quot;image/pjpeg&quot;)<br>            {<br>                string name = FileUpload1.PostedFile.FileName; // 客户端文件路径<br><br>                FileInfo file = new FileInfo(name);<br>                string fileName = file.Name; // 文件名称<br>                string fileName_s = &quot;s_&quot; + file.Name; // 缩略图文件名称<br>                string fileName_sy = &quot;sy_&quot; + file.Name; // 水印图文件名称（文字）<br>                string fileName_syp = &quot;syp_&quot; + file.Name; // 水印图文件名称（图片）<br>                string webFilePath = Server.MapPath(&quot;file/&quot; + fileName); // 服务器端文件路径<br>                string webFilePath_s = Server.MapPath(&quot;file/&quot; + fileName_s);　　// 服务器端缩略图路径<br>                string webFilePath_sy = Server.MapPath(&quot;file/&quot; + fileName_sy);　// 服务器端带水印图路径(文字)<br>                string webFilePath_syp = Server.MapPath(&quot;file/&quot; + fileName_syp);　// 服务器端带水印图路径(图片)<br>                string webFilePath_sypf = Server.MapPath(&quot;file/shuiyin.jpg&quot;);　// 服务器端水印图路径(图片)<br><br>                if (!File.Exists(webFilePath))<br>                {<br>                    try<br>                    {<br>                        FileUpload1.SaveAs(webFilePath); // 使用 SaveAs 方法保存文件<br>                        AddShuiYinWord(webFilePath, webFilePath_sy);<br>                        AddShuiYinPic(webFilePath, webFilePath_syp, webFilePath_sypf);<br>                        MakeThumbnail(webFilePath, webFilePath_s, 130, 130, &quot;Cut&quot;); // 生成缩略图方法<br>                        Label1.Text = &quot;提示：文件“&quot; + fileName + &quot;”成功上传，并生成“&quot; + fileName_s + &quot;”缩略图，文件类型为：&quot; +<br>                        FileUpload1.PostedFile.ContentType + &quot;，文件大小为：&quot; + FileUpload1.PostedFile.ContentLength + &quot;B&quot;;<br>                    }<br>                    catch (Exception ex)<br>                    {<br>                        Label1.Text = &quot;提示：文件上传失败，失败原因：&quot; + ex.Message;<br>                    }<br>                }<br>                else<br>                {<br>                    Label1.Text = &quot;提示：文件已经存在，请重命名后上传&quot;;<br>                }<br>            }<br>            else<br>            {<br>                Label1.Text = &quot;提示：文件类型不符&quot;;<br>            }<br>        }<br>    }<br><br>    /// &lt;summary&gt;<br>    /// 生成缩略图<br>    /// &lt;/summary&gt;<br>    /// &lt;param name=&quot;originalImagePath&quot;&gt;源图路径（物理路径）&lt;/param&gt;<br>    /// &lt;param name=&quot;thumbnailPath&quot;&gt;缩略图路径（物理路径）&lt;/param&gt;<br>    /// &lt;param name=&quot;width&quot;&gt;缩略图宽度&lt;/param&gt;<br>    /// &lt;param name=&quot;height&quot;&gt;缩略图高度&lt;/param&gt;<br>    /// &lt;param name=&quot;mode&quot;&gt;生成缩略图的方式&lt;/param&gt;   <br>    public static void MakeThumbnail(string originalImagePath, string thumbnailPath, int width, int height, string mode)<br>    {<br>        System.Drawing.Image originalImage = System.Drawing.Image.FromFile(originalImagePath);<br><br>        int towidth = width;<br>        int toheight = height;<br><br>        int x = 0;<br>        int y = 0;<br>        int ow = originalImage.Width;<br>        int oh = originalImage.Height;<br><br>        switch (mode)<br>        {<br>            case &quot;HW&quot;://指定高宽缩放（可能变形） <br>                break;<br>            case &quot;W&quot;://指定宽，高按比例 <br>                toheight = originalImage.Height * width / originalImage.Width;<br>                break;<br>            case &quot;H&quot;://指定高，宽按比例<br>                towidth = originalImage.Width * height / originalImage.Height;<br>                break;<br>            case &quot;Cut&quot;://指定高宽裁减（不变形） <br>                if ((double)originalImage.Width / (double)originalImage.Height &gt; (double)towidth / (double)toheight)<br>                {<br>                    oh = originalImage.Height;<br>                    ow = originalImage.Height * towidth / toheight;<br>                    y = 0;<br>                    x = (originalImage.Width - ow) / 2;<br>                }<br>                else<br>                {<br>                    ow = originalImage.Width;<br>                    oh = originalImage.Width * height / towidth;<br>                    x = 0;<br>                    y = (originalImage.Height - oh) / 2;<br>                }<br>                break;<br>            default:<br>                break;<br>        }<br><br>        //新建一个bmp图片<br>        System.Drawing.Image bitmap = new System.Drawing.Bitmap(towidth, toheight);<br><br>        //新建一个画板<br>        System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bitmap);<br><br>        //设置高质量插值法<br>        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;<br><br>        //设置高质量,低速度呈现平滑程度<br>        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;<br><br>        //清空画布并以透明背景色填充<br>        g.Clear(System.Drawing.Color.Transparent);<br><br>        //在指定位置并且按指定大小绘制原图片的指定部分<br>        g.DrawImage(originalImage, new System.Drawing.Rectangle(0, 0, towidth, toheight),<br>            new System.Drawing.Rectangle(x, y, ow, oh),<br>            System.Drawing.GraphicsUnit.Pixel);<br><br>        try<br>        {<br>           //以jpg格式保存缩略图<br>            bitmap.Save(thumbnailPath, System.Drawing.Imaging.ImageFormat.Jpeg);<br>        }<br>        catch (System.Exception e)<br>        {<br>            throw e;<br>        }<br>        finally<br>        {<br>            originalImage.Dispose();<br>            bitmap.Dispose();<br>            g.Dispose();<br>        }<br>    }<br><br><br>    /// &lt;summary&gt;<br>    /// 在图片上增加文字水印<br>    /// &lt;/summary&gt;<br>    /// &lt;param name=&quot;Path&quot;&gt;原服务器图片路径&lt;/param&gt;<br>    /// &lt;param name=&quot;Path_sy&quot;&gt;生成的带文字水印的图片路径&lt;/param&gt;<br>    protected void AddShuiYinWord(string Path, string Path_sy)<br>    {<br>        string addText = &quot;测试水印&quot;;<br>        System.Drawing.Image image = System.Drawing.Image.FromFile(Path);<br>        System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);<br>        g.DrawImage(image, 0, 0, image.Width, image.Height);<br>        System.Drawing.Font f = new System.Drawing.Font(&quot;Verdana&quot;, 16);<br>        System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);<br><br>        g.DrawString(addText, f, b, 15, 15);<br>        g.Dispose();<br><br>        image.Save(Path_sy);<br>        image.Dispose();<br>    }<br><br><br>    /// &lt;summary&gt;<br>    /// 在图片上生成图片水印<br>    /// &lt;/summary&gt;<br>    /// &lt;param name=&quot;Path&quot;&gt;原服务器图片路径&lt;/param&gt;<br>    /// &lt;param name=&quot;Path_syp&quot;&gt;生成的带图片水印的图片路径&lt;/param&gt;<br>    /// &lt;param name=&quot;Path_sypf&quot;&gt;水印图片路径&lt;/param&gt;<br>    protected void AddShuiYinPic(string Path, string Path_syp, string Path_sypf)<br>    {<br>        System.Drawing.Image image = System.Drawing.Image.FromFile(Path);<br>        System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);<br>        System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);<br>        g.DrawImage(copyImage, new System.Drawing.Rectangle(image.Width - copyImage.Width, image.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, System.Drawing.GraphicsUnit.Pixel);<br>        g.Dispose();<br><br>        image.Save(Path_syp);<br>        image.Dispose();<br>    }<br>}<br><br><br><div align=right><a style="text-decoration:none;" href="http://www.cnblogs.com/yaoo/" target="_blank">liong</a> 2008-04-03 23:25 <a href="http://www.cnblogs.com/yaoo/archive/2008/04/03/1136358.html#1136930#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>
