天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

C# 添加文字水印類代碼

復制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
namespace Chen
{
public class warterfont
{
public void addtexttoimg(string filename, string text)
{
if (!File.Exists(System.Web.HttpContext.Current.Server.MapPath(filename)))
{
throw new FileNotFoundException("the file don't exist!");
}
if (text == string.Empty)
{
return;
}
//還需要判斷文件類型是否為圖像類型,這里就不贅述了
Image image = Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(filename));
Bitmap bitmap = new Bitmap(image, image.Width, image.Height);
Graphics g = Graphics.FromImage(bitmap);
float fontsize = 12.0f; //字體大小
float textwidth = text.Length * fontsize; //文本的長度
//下面定義一個矩形區域,以后在這個矩形里畫上白底黑字
float rectx = 0;
float recty = 0;
float rectwidth = text.Length * (fontsize + 8);
float rectheight = fontsize + 8; //聲明矩形域
RectangleF textarea = new RectangleF(rectx, recty, rectwidth, rectheight);
Font font = new Font("宋體", fontsize); //定義字體
Brush whitebrush = new SolidBrush(Color.White); //白筆刷,畫文字用
Brush blackbrush = new SolidBrush(Color.Black); //黑筆刷,畫背景用
g.FillRectangle(blackbrush, rectx, recty, rectwidth, rectheight);
g.DrawString(text, font, whitebrush, textarea);
MemoryStream ms = new MemoryStream(); //保存為jpg類型
bitmap.Save(ms, ImageFormat.Jpeg); //輸出處理后的圖像,這里為了演示方便,我將圖片顯示在頁面中了
bitmap.Save(System.Web.HttpContext.Current.Server.MapPath("/" + "aa.jpg"), ImageFormat.Jpeg); //保存到磁盤上
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ContentType = "image/jpeg";
System.Web.HttpContext.Current.Response.BinaryWrite(ms.ToArray());
g.Dispose();
bitmap.Dispose();
image.Dispose();
}
}
}

AspNet技術C# 添加文字水印類代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 亚洲高清有码中文字 | 国产亚洲色婷婷久久精品99 | 一二三四在线高清中文版免费观看电影 | 国产爱豆果冻传媒在线观看 | 久久伊人青青 | 乌克兰黄色录像 | 三级网址在线观看 | 健身房被教练啪到腿软H | 幼儿交1300部一区二区 | 视频一区国产在线二区 | 国产人成精品综合欧美成人 | 欧洲最大无人区免费高清完整版 | 国产高清视频在线播放www色 | DASD-700美谷朱里| 动漫H片在线观看播放免费 动漫H片在线播放免费高清 | 天美传媒果冻传媒入口视频 | 青草国产超碰人人添人人碱 | 亚洲成人一区二区 | 成人网视频在线观看免费 | 99精品免费久久久久久久久日本 | 麻豆免费观看高清完整视频在线 | 欧美精品AV无码一区二区 | 亚洲精品久久久无码一区二区 | 欧式午夜理伦三级在线观看 | 久久综合中文字幕佐佐木希 | 久久久影院亚洲精品 | YELLOW高清视频免费观看 | 全彩无翼污之邪恶女教师 | 草莓AV福利网站导航 | 幺妹视频福利视频 | 中文字幕天堂久久精品 | caoporm国产精品视频免费 | 国产99久久九九精品无码不卡 | 亲女乱h文小兰第一次 | 亚洲精品国产精麻豆久久99 | 国产成人免费片在线观看 | 精品伊人久久久 | 纯肉高H种马艳遇风流多 | 岛国大片在线观看完整版 | 久久人人玩人妻潮喷内射人人 | 国产精品涩涩涩视频网站 |