打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Asp.net(C#)给图片加上水印效果
if (FileUpload1.PostedFile.ContentType.ToLower().IndexOf("image") < 0)
 2        {
 3            FunctionUtility.JavaScriptHelper.Alert("上传的文件格式不正确!");
 4            return;
 5        }
 6
 7        Stream oStream = FileUpload1.PostedFile.InputStream;
 8        System.Drawing.Image oImage = System.Drawing.Image.FromStream(oStream);
 9
10        if(CheckBox1.Checked)
11        {
12            //加文字水印
13            Graphics g = Graphics.FromImage(oImage);
14            g.DrawImage(oImage, 0, 0, oImage.Width, oImage.Height);
15            Font f = new Font("Verdana",15);
16            Brush b = new SolidBrush(Color.White);
17            g.DrawString("http://www.itwealth.cn制作", f, b, 0, oImage.Height - 30);
18            g.Dispose();
19        }
20        else
21        {
22            //加图片水印
23            System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Server.MapPath("/DesignImages/Images/SYT/Admin.jpg"));
24            Graphics g = Graphics.FromImage(oImage);
25            g.DrawImage(copyImage, new Rectangle(oImage.Width - copyImage.Width, oImage.Height - copyImage.Height, copyImage.Width, copyImage.Height), 0, 0, copyImage.Width, copyImage.Height, GraphicsUnit.Pixel);
26            g.Dispose();
27        }
28
29        string setFileName = FunctionUtility.FileHelper.GetDateTimeFileName() + ".jpg";
30        string oFullName = Server.MapPath("/DesignImages/Images/SYT/" + setFileName);
31        oImage.Save(oFullName, System.Drawing.Imaging.ImageFormat.Jpeg);
32        oImage.Dispose();
33
34        Image1.Visible = true;
35        Image1.ImageUrl = "/DesignImages/Images/SYT/" + setFileName;
36        FunctionUtility.JavaScriptHelper.Alert("水印加载成功!");
 
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/masky5310/archive/2009/11/22/4852110.aspx
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
ASP.NET通过URL将图片下载到电脑本地文件夹
CAD颜色代码
vb.net 、c# 、GDI 分解显示GIF图片
ASP.NET中各命名空间及作用
C#GDI+编程基础(一:Graphics画布类)
DevExpress的TreeList怎样给树节点设置图标
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服