惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - speshow

初涉SQL Server性能问题(4/4):列出最耗资源的会话 初涉SQL Server性能问题(3/4):列出阻塞的会话 初涉SQL Server性能问题(2/4):列出等待资源的会话 初涉SQL Server性能问题(1/4):服务器概况 分享 大型网站的架构设计问题--大型高并发高负载网站的系统架构 Android应用程序运行机制解析 js 小小jquery等比例缩放图片效果 - speshow - 博客园 .net 发送手机短信息 C#实现汉字转换为拼音缩写的代码 .net 导出海量数据到execl文件 - speshow - 博客园 IIs6+Rewrite+asp+php5+mysql5 .net 生成二级域名 用VSTS进行网站压力测试 各种JAVASCRIPT技巧 使用ASP.NET画饼状图 - speshow - 博客园 我们到底为了什么钻研技术? aspnetpager 分页 Jquery 服务器回调为select填值
生成图片水印
speshow · 2008-06-24 · via 博客园 - speshow

using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
  
using System.Drawing;
protected void AddShuiYinWord(string Path, string Path_sy)
  {
   string addText = "测试水印";
   System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
   System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);
   g.DrawImage(image, 0, 0, image.Width, image.Height);
   System.Drawing.Font f = new System.Drawing.Font("Verdana", 16);
   System.Drawing.Brush b = new System.Drawing.SolidBrush(System.Drawing.Color.Blue);

   g.DrawString(addText, f, b, 15, 15);
   g.Dispose();

   image.Save(Path_sy);
   image.Dispose();
  }

  /**/
  /// <summary>
  /// 在图片上生成图片水印
  /// </summary>
  /// <param name="Path">原服务器图片路径</param>
  /// <param name="Path_syp">生成的带图片水印的图片路径</param>
  /// <param name="Path_sypf">水印图片路径</param>
  protected void AddShuiYinPic(string Path, string Path_syp, string Path_sypf)
  {
   System.Drawing.Image image = System.Drawing.Image.FromFile(Path);
   System.Drawing.Image copyImage = System.Drawing.Image.FromFile(Path_sypf);
   //System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(image);

   Bitmap newBitmap = new Bitmap(image.Width, image.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
   newBitmap.SetResolution(image.HorizontalResolution, image.VerticalResolution);
   Graphics g = Graphics.FromImage(newBitmap);
   g.SmoothingMode = SmoothingMode.AntiAlias;
   g.DrawImage(image, new Rectangle(0, 0, image.Width, image.Height), 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
   g.Dispose();
   System.IO.MemoryStream ms = new System.IO.MemoryStream();
   newBitmap.Save(ms, ImageFormat.Jpeg);
   //重新生成Image对象
   image = System.Drawing.Image.FromStream(ms);

   g = System.Drawing.Graphics.FromImage(image);

   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);
   g.Dispose();
   
   image.Save(Path_syp);
   image.Dispose();
copyImage.Dispose();
  }