代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
CSharp
】
水印及缩略图的C#实现
作者:
Dezai.CN
/ 发布于
2011/6/2
/
533
<div><span style="color: rgb(0,0,255)">using</span><span style="color: rgb(0,0,0)"> System; </span><span style="color: rgb(0,0,255)">using</span><span style="color: rgb(0,0,0)"> System.IO; </span><span style="color: rgb(0,0,255)">using</span><span style="color: rgb(0,0,0)"> System.Drawing; </span><span style="color: rgb(0,0,255)">using</span><span style="color: rgb(0,0,0)"> System.Drawing.Imaging; </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> PictureMarker 的摘要说明。 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">class</span><span style="color: rgb(0,0,0)"> PictureMarker { </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> PictureMarker的构造函数 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> PictureMarker() { } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> PictureMarker的构造函数 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="width"></span><span style="color: rgb(0,128,0)">缩略图的宽度</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="height"></span><span style="color: rgb(0,128,0)">缩略图的高度</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="ismust"></span><span style="color: rgb(0,128,0)">是否一定要生成缩略图,推荐为false</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> PictureMarker(</span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> width, </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> height, </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> ismust) { </span><span style="color: rgb(0,0,255)">this</span><span style="color: rgb(0,0,0)">.width </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> width; </span><span style="color: rgb(0,0,255)">this</span><span style="color: rgb(0,0,0)">.height </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> height; </span><span style="color: rgb(0,0,255)">this</span><span style="color: rgb(0,0,0)">.ismust </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> ismust; } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> PictureMarker的构造函数 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="width"></span><span style="color: rgb(0,128,0)">缩略图的宽度</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="height"></span><span style="color: rgb(0,128,0)">缩略图的高度</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="ismust"></span><span style="color: rgb(0,128,0)">是否一定要生成缩略图,推荐为false</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="isSavePrimaryPic"></span><span style="color: rgb(0,128,0)">是否要保存源图片</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="primaryPicPath"></span><span style="color: rgb(0,128,0)">源图片的保存目录</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> PictureMarker(</span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> width, </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> height, </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> ismust, </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> isSavePrimaryPic, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> primaryPicPath) : </span><span style="color: rgb(0,0,255)">this</span><span style="color: rgb(0,0,0)">(width, height, ismust) { </span><span style="color: rgb(0,0,255)">this</span><span style="color: rgb(0,0,0)">.isSavePrimaryPic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> isSavePrimaryPic; </span><span style="color: rgb(0,0,255)">this</span><span style="color: rgb(0,0,0)">.primaryPicPath </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> primaryPicPath; } </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> width; </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> height; </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> ismust </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> isSavePrimaryPic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">false</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">private</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> primaryPicPath; </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 缩略图的宽度 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> Width { </span><span style="color: rgb(0,0,255)">get</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> width; } </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> { width </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> value; } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 缩略图的高度 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> Height { </span><span style="color: rgb(0,0,255)">get</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> height; } </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> { height </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> value; } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 是否一定要生成缩略图,推荐为false </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsMust { </span><span style="color: rgb(0,0,255)">get</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> ismust; } </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> { ismust </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> value; } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 是否要保存源图片 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> IsSavePrimaryPic { </span><span style="color: rgb(0,0,255)">get</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> isSavePrimaryPic; } </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> { isSavePrimaryPic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> value; } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 源图片的保存目录 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> PrimaryPicPath { </span><span style="color: rgb(0,0,255)">get</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">return</span><span style="color: rgb(0,0,0)"> primaryPicPath; } </span><span style="color: rgb(0,0,255)">set</span><span style="color: rgb(0,0,0)"> { primaryPicPath </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> value; } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 在图片上添加版权信息水印 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">目标图片</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="copyright"></span><span style="color: rgb(0,128,0)">文字版权信息</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="savepath"></span><span style="color: rgb(0,128,0)">保存路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="position"></span><span style="color: rgb(0,128,0)">水印显示位置</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateMark(Stream input, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> copyright, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> savepath, WaterPosition position) { </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> xpoint, ypoint; System.Drawing.Image photo </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> System.Drawing.Image.FromStream(input); </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> pwidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> photo.Width; </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> pheight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> photo.Height; Bitmap markpic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Bitmap(photo); markpic.SetResolution(photo.HorizontalResolution, photo.VerticalResolution); Graphics graphics </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Graphics.FromImage(markpic); xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">100</span><span style="color: rgb(0,0,0)">) </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">2</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">40</span><span style="color: rgb(0,0,0)">; graphics.DrawString(copyright, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Font(</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">楷体</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">15</span><span style="color: rgb(0,0,0)">), </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> System.Drawing.SolidBrush(Color.FromArgb(</span><span style="color: rgb(0,0,0)">255</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">255</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">255</span><span style="color: rgb(0,0,0)">)), </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> RectangleF(xpoint, ypoint, </span><span style="color: rgb(0,0,0)">400</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">30</span><span style="color: rgb(0,0,0)">)); </span><span style="color: rgb(0,0,255)">try</span><span style="color: rgb(0,0,0)"> { markpic.Save(savepath); } </span><span style="color: rgb(0,0,255)">finally</span><span style="color: rgb(0,0,0)"> { input.Close(); photo.Dispose(); markpic.Dispose(); graphics.Dispose(); } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 在图片上添加版权信息水印 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">目标图片</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="copyright"></span><span style="color: rgb(0,128,0)">图片版权信息</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="savepath"></span><span style="color: rgb(0,128,0)">保存路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="position"></span><span style="color: rgb(0,128,0)">水印显示位置</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateMark(Stream input, Stream copyright, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> savepath, WaterPosition position) { </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> xpoint, ypoint; System.Drawing.Image photo </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> System.Drawing.Image.FromStream(input); System.Drawing.Image copy </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> System.Drawing.Image.FromStream(copyright); </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> pwidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> photo.Width; </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> pheight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> photo.Height; </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> cwidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> copy.Width; </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> cheight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> copy.Height; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cwidth </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">20</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cheight </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">20</span><span style="color: rgb(0,0,0)">) { input.Close(); copyright.Close(); photo.Dispose(); copy.Dispose(); </span><span style="color: rgb(0,0,255)">throw</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> ArgumentException(</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">不合适的图片尺寸.目标图片比版权图片至少宽20像素,高20像素.</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (isSavePrimaryPic) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (primaryPicPath </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> primaryPicPath </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">""</span><span style="color: rgb(0,0,0)">) { input.Close(); copyright.Close(); photo.Dispose(); copy.Dispose(); </span><span style="color: rgb(0,0,255)">throw</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> ArgumentException(</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">当要求保存源图片时,源图片的保存路径不能为空</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">try</span><span style="color: rgb(0,0,0)"> { photo.Save(primaryPicPath </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">\\</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> Path.GetFileName(savepath) </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">.jpg</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">, ImageFormat.Jpeg); } </span><span style="color: rgb(0,0,255)">catch</span><span style="color: rgb(0,0,0)"> (Exception ex) { input.Close(); copyright.Close(); photo.Dispose(); copy.Dispose(); </span><span style="color: rgb(0,0,255)">throw</span><span style="color: rgb(0,0,0)"> ex; } } Bitmap markpic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Bitmap(photo); markpic.SetResolution(photo.HorizontalResolution, photo.VerticalResolution); Graphics graphics </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Graphics.FromImage(markpic); System.Drawing.Imaging.ImageAttributes att </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> System.Drawing.Imaging.ImageAttributes(); </span><span style="color: rgb(0,0,255)">float</span><span style="color: rgb(0,0,0)">[][] matrixelements </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">float</span><span style="color: rgb(0,0,0)">[] {</span><span style="color: rgb(0,0,0)">1.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">}, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">float</span><span style="color: rgb(0,0,0)">[] {</span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">1.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">}, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">float</span><span style="color: rgb(0,0,0)">[] {</span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">1.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">}, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">float</span><span style="color: rgb(0,0,0)">[] {</span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.5f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">}, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">float</span><span style="color: rgb(0,0,0)">[] {</span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0.0f</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">1.0f</span><span style="color: rgb(0,0,0)">}}; System.Drawing.Imaging.ColorMatrix matrix </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> System.Drawing.Imaging.ColorMatrix(matrixelements); att.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); </span><span style="color: rgb(0,0,255)">switch</span><span style="color: rgb(0,0,0)"> (position) { </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.Left: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cheight) </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">2</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.LeftUp: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.MiddleUp: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cwidth) </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">2</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.RightUp: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.Right: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cheight) </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">2</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.RightDown: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.MiddleDown: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cwidth) </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">2</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">case</span><span style="color: rgb(0,0,0)"> WaterPosition.LeftDown: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">10</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">default</span><span style="color: rgb(0,0,0)">: xpoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (pwidth </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cwidth) </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">2</span><span style="color: rgb(0,0,0)">; ypoint </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (pheight </span><span style="color: rgb(0,0,0)">-</span><span style="color: rgb(0,0,0)"> cheight) </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">2</span><span style="color: rgb(0,0,0)">; </span><span style="color: rgb(0,0,255)">break</span><span style="color: rgb(0,0,0)">; }; graphics.DrawImage(copy, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Rectangle(xpoint, ypoint, cwidth, cheight), </span><span style="color: rgb(0,0,0)">0</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,0)">0</span><span style="color: rgb(0,0,0)">, cwidth, cheight, GraphicsUnit.Pixel, att); </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (width </span><span style="color: rgb(0,0,0)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">0</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">&&</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">!=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">0</span><span style="color: rgb(0,0,0)">) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (ismust) { </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> twidth, theight; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width) { twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> width; theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Width; } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> height; twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Height; } markpic.SetResolution(twidth, theight); markpic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (Bitmap)markpic.GetThumbnailImage(twidth, theight, </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> IntPtr()); } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (width </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Height) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (width </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Height) { </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> twidth, theight; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width) { twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> width; theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Width; } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> height; twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Height; } markpic.SetResolution(twidth, theight); markpic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (Bitmap)markpic.GetThumbnailImage(twidth, theight, </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> IntPtr()); } } } } </span><span style="color: rgb(0,0,255)">try</span><span style="color: rgb(0,0,0)"> { markpic.Save(savepath, ImageFormat.Jpeg); } </span><span style="color: rgb(0,0,255)">finally</span><span style="color: rgb(0,0,0)"> { graphics.Dispose(); input.Close(); copyright.Close(); photo.Dispose(); copy.Dispose(); markpic.Dispose(); } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 在图片上添加版权信息水印 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">目标图片</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="copyright"></span><span style="color: rgb(0,128,0)">版权信息,可以为图片路径或文字版权信息</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="directory"></span><span style="color: rgb(0,128,0)">保存目录</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="filename"></span><span style="color: rgb(0,128,0)">保存文件名</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="isDrectory"></span><span style="color: rgb(0,128,0)">copyright是否为文件路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="position"></span><span style="color: rgb(0,128,0)">水印显示位置</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateMark(Stream input, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> copyright, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> directory, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> filename, </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> isDrectory, WaterPosition position) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (isDrectory) { FileStream _copyright </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> FileStream(copyright, FileMode.Open, FileAccess.Read, FileShare.Read); CreateMark(input, _copyright, directory, filename, position); } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { CreateMark(input, copyright, directory </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">\\</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> filename, position); } } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 在图片上添加版权信息水印 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="input"></span><span style="color: rgb(0,128,0)">目标图片</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="copyright"></span><span style="color: rgb(0,128,0)">图片版权信息</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="directory"></span><span style="color: rgb(0,128,0)">保存目录</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="filename"></span><span style="color: rgb(0,128,0)">保存文件名</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="position"></span><span style="color: rgb(0,128,0)">水印显示位置</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateMark(Stream input, Stream copyright, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> directory, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> filename, WaterPosition position) { CreateMark(input, copyright, directory </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">\\</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> filename, position); } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 在图片上添加版权信息水印 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="filepath"></span><span style="color: rgb(0,128,0)">目标图片路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="copyright"></span><span style="color: rgb(0,128,0)">版权信息,可以为图片路径或文字版权信息</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="directory"></span><span style="color: rgb(0,128,0)">保存目录</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="filename"></span><span style="color: rgb(0,128,0)">保存文件名</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="isDrectory"></span><span style="color: rgb(0,128,0)">copyright是否为文件路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="position"></span><span style="color: rgb(0,128,0)">水印显示位置</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateMark(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> filepath, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> copyright, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> directory, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> filename, </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> isDrectory, WaterPosition position) { FileStream input </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> FileStream(filepath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read); CreateMark(input, copyright, directory, filename, isDrectory, position); } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 在图片上添加版权信息水印 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="filepath"></span><span style="color: rgb(0,128,0)">目标图片路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="copyright"></span><span style="color: rgb(0,128,0)">版权信息,可以为图片路径或文字版权信息</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="savepath"></span><span style="color: rgb(0,128,0)">保存路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="isDrectory"></span><span style="color: rgb(0,128,0)">copyright是否为文件路径</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><param name="position"></span><span style="color: rgb(0,128,0)">水印显示位置</span><span style="color: rgb(128,128,128)"></param></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateMark(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> filepath, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> copyright, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> savepath, </span><span style="color: rgb(0,0,255)">bool</span><span style="color: rgb(0,0,0)"> isDrectory, WaterPosition position) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (isDrectory) { FileStream input </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> FileStream(filepath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read); FileStream _copyright </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> FileStream(copyright, FileMode.Open, FileAccess.Read, FileShare.Read); CreateMark(input, _copyright, savepath, position); } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { FileStream input </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> FileStream(filepath, FileMode.Open, FileAccess.ReadWrite, FileShare.Read); CreateMark(input, copyright, savepath, position); } } </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateThumbnailImage(Stream input, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> savepath) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (width </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">0</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">0</span><span style="color: rgb(0,0,0)">) { input.Close(); </span><span style="color: rgb(0,0,255)">throw</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> ArgumentException(</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">缩略图的宽度和高度不能为0.</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">); } Image photo </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> Image.FromStream(input); </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (isSavePrimaryPic) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (primaryPicPath </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> primaryPicPath </span><span style="color: rgb(0,0,0)">==</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">""</span><span style="color: rgb(0,0,0)">) { input.Close(); photo.Dispose(); </span><span style="color: rgb(0,0,255)">throw</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> ArgumentException(</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">当要求保存源图片时,源图片的保存路径不能为空</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">); } </span><span style="color: rgb(0,0,255)">try</span><span style="color: rgb(0,0,0)"> { photo.Save(Path.Combine(primaryPicPath, Path.GetFileNameWithoutExtension(savepath) </span><span style="color: rgb(0,0,0)">+</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">.jpg</span><span style="color: rgb(0,0,0)">"</span><span style="color: rgb(0,0,0)">), ImageFormat.Jpeg); } </span><span style="color: rgb(0,0,255)">catch</span><span style="color: rgb(0,0,0)"> (Exception ex) { input.Close(); photo.Dispose(); </span><span style="color: rgb(0,0,255)">throw</span><span style="color: rgb(0,0,0)"> ex; } } Bitmap markpic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> Bitmap(photo); </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (ismust) { </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> twidth, theight; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width) { twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> width; theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Width; } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> height; twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Height; } markpic.SetResolution(twidth, theight); markpic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (Bitmap)markpic.GetThumbnailImage(twidth, theight, </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> IntPtr()); } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (width </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Height) { </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (width </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">||</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)"><</span><span style="color: rgb(0,0,0)"> markpic.Height) { </span><span style="color: rgb(0,0,255)">int</span><span style="color: rgb(0,0,0)"> twidth, theight; </span><span style="color: rgb(0,0,255)">if</span><span style="color: rgb(0,0,0)"> (markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">></span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width) { twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> width; theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Height </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> width </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Width; } </span><span style="color: rgb(0,0,255)">else</span><span style="color: rgb(0,0,0)"> { theight </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> height; twidth </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> markpic.Width </span><span style="color: rgb(0,0,0)">*</span><span style="color: rgb(0,0,0)"> height </span><span style="color: rgb(0,0,0)">/</span><span style="color: rgb(0,0,0)"> markpic.Height; } markpic.SetResolution(twidth, theight); markpic </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> (Bitmap)markpic.GetThumbnailImage(twidth, theight, </span><span style="color: rgb(0,0,255)">null</span><span style="color: rgb(0,0,0)">, </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> IntPtr()); } } } </span><span style="color: rgb(0,0,255)">try</span><span style="color: rgb(0,0,0)"> { markpic.Save(savepath, ImageFormat.Jpeg); } </span><span style="color: rgb(0,0,255)">finally</span><span style="color: rgb(0,0,0)"> { input.Close(); photo.Dispose(); markpic.Dispose(); } } </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)"> CreateThumbnailImage(</span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> source, </span><span style="color: rgb(0,0,255)">string</span><span style="color: rgb(0,0,0)"> savepath) { FileStream input </span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)"> FileStream(source, FileMode.Open, FileAccess.ReadWrite, FileShare.Read); CreateThumbnailImage(input, savepath); } </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 水印显示的位置 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)"> </span><span style="color: rgb(0,0,255)">enum</span><span style="color: rgb(0,0,0)"> WaterPosition { </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 左上 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">LeftUp, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 中上 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">MiddleUp, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 右上 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">RightUp, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 右 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">Right, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 右下 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">RightDown, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 中下 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">MiddleDown, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 左下 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">LeftDown, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 左 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">Left, </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"><summary></span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> 正中间 </span><span style="color: rgb(128,128,128)">///</span><span style="color: rgb(0,128,0)"> </span><span style="color: rgb(128,128,128)"></summary></span><span style="color: rgb(128,128,128)"> </span><span style="color: rgb(0,0,0)">Middle } }</span></div>
试试其它关键字
水印及缩略图
同语言下
.
文件IO 操作类库
.
Check图片类型[JPEG(.jpg 、.jpeg),TIF,GIF,BMP,PNG,P
.
机器名和IP取得(IPV4 IPV6)
.
Tiff转换Bitmap
.
linqHelper
.
MadieHelper.cs
.
RegHelper.cs
.
如果关闭一个窗体后激活另一个窗体的事件或方法
.
创建日志通用类
.
串口辅助开发类
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3