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

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
量子位
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
雷峰网
雷峰网
I
InfoQ
罗磊的独立博客
博客园 - 聂微东
酷 壳 – CoolShell
酷 壳 – CoolShell
大猫的无限游戏
大猫的无限游戏
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
腾讯CDC
博客园 - 三生石上(FineUI控件)
The GitHub Blog
The GitHub Blog
K
Kaspersky official blog
P
Privacy & Cybersecurity Law Blog
S
SegmentFault 最新的问题
T
Threat Research - Cisco Blogs
H
Help Net Security
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
CERT Recently Published Vulnerability Notes
WordPress大学
WordPress大学
T
Tenable Blog
T
The Blog of Author Tim Ferriss
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - Franky
A
Arctic Wolf
T
Threatpost
Scott Helme
Scott Helme
C
Cybersecurity and Infrastructure Security Agency CISA
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
The Exploit Database - CXSecurity.com
G
GRAHAM CLULEY
Security Latest
Security Latest
Spread Privacy
Spread Privacy
L
LINUX DO - 热门话题
V
Vulnerabilities – Threatpost
P
Privacy International News Feed
S
Schneier on Security
Latest news
Latest news
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com

博客园 - 东哥

MongoVUE 错误:can't map file memory - mongo requires 64 bit build for larger datasets HTTP Header 属性列表 安装卸载Windows服务,修改windows服务执行路径! SQL 语句嵌套,自己记录下。 基于RBAC的权限设计模型 javascript中getElementsByName的问题 三级连动JS数据库查询代码整理 动态添加WEB控件,点控件获取动态添加的控件 数据库基本----SQL语句大全 使用Ajax时的十个常犯的错误 数据采集程序(网页小偷)点滴心得 WEB Service 下实现大数据量的传输 我奋斗了18年不是为了和你一起喝咖啡(转载) [转]社区好友列表利用率越高,社区越失败 很实用的一个图片上传得例子 [转帖]教程:使用WebService进行异步通信 如何用Javascript记录登陆次数 很酷实用的右键弹出菜单(Js+DVML) JavaScript如果文字过长,则将过长的部分变成省略号显示
[转]将上传图片打上防伪图片水印并写入数据库
东哥 · 2008-05-09 · via 博客园 - 东哥

// 涉及命名空间
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Web;
using System.Configuration;

// 方法
public void AddUser(string PersonName, string PersonEmail, string PersonSex, string PersonDOB, string PersonImage, string PersonImageType)
{
 string strImageType = userImage.PostedFile.ContentType;
 Stream ImageStream = userImage.PostedFile.InputStream;

 // 加水印----------------->
 string wImageFile = Server.MapPath("/bkwww/image/HomeSign.gif"); // 要加的水印图
 Image sImage = Image.FromStream(ImageStream); // 从 Http 输入流创建 image
 Image wImage = Image.FromFile(wImageFile);

 // 绘图
 Graphics g = Graphics.FromImage(sImage);
 g.DrawImage(wImage, new Rectangle(0, 0, wImage.Width, wImage.Height), 0, 0, wImage.Width, wImage.Height, GraphicsUnit.Pixel);
  
 // 保存,并将 image 转化为 byte[]
 MemoryStream ms=new MemoryStream();
 byte[] myImage=null;
 sImage.Save(ms, ImageFormat.Gif);
 myImage = ms.GetBuffer();
 //------------------------>
  

 // 写入数据库
 string strConn = ConfigurationSettings.AppSettings["ConnectionString"];
 SqlConnection myConnection = new SqlConnection(strConn);
 SqlCommand myCommand = new SqlCommand("sp_person_isp", myConnection);
 myCommand.CommandType = CommandType.StoredProcedure;

 myCommand.Parameters.Add("@PersonEmail", SqlDbType.VarChar, 255).Value = PersonEmail;
 myCommand.Parameters.Add("@PersonName", SqlDbType.VarChar, 255).Value = PersonName;
 myCommand.Parameters.Add("@PersonSex", SqlDbType.Char, 1);
 if(sexMale.Checked)
 myCommand.Parameters["@PersonSex"].Value = "M";
 else
 myCommand.Parameters["@PersonSex"].Value = "F";
 myCommand.Parameters.Add("@PersonDOB", SqlDbType.DateTime).Value = PersonDOB;
 myCommand.Parameters.Add("@PersonImage", SqlDbType.Image).Value = myImage;
 myCommand.Parameters.Add("@PersonImageType", SqlDbType.VarChar, 255).Value = ImageType;

 try
 {
 myConnection.Open();
 myCommand.ExecuteNonQuery();
 myConnection.Close();
 Response.Write("添加成功!");
 }
 catch(System.Exception SqlEx)
 {
 Response.Write("添加失败!"+SqlEx.ToString());
 }
}

/*
 54tiger.cnblogs.com
   Copyright(c) 2006 《八零年代》 Function:将上传的图片添加防伪图片水印,并将图片直接写入数据库,不保留在硬盘。
*/