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

C# 添加文字水印類(lèi)代碼

復(fù)制代碼 代碼如下:
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;
}
//還需要判斷文件類(lèi)型是否為圖像類(lèi)型,這里就不贅述了
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; //文本的長(zhǎng)度
//下面定義一個(gè)矩形區(qū)域,以后在這個(gè)矩形里畫(huà)上白底黑字
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); //白筆刷,畫(huà)文字用
Brush blackbrush = new SolidBrush(Color.Black); //黑筆刷,畫(huà)背景用
g.FillRectangle(blackbrush, rectx, recty, rectwidth, rectheight);
g.DrawString(text, font, whitebrush, textarea);
MemoryStream ms = new MemoryStream(); //保存為jpg類(lèi)型
bitmap.Save(ms, ImageFormat.Jpeg); //輸出處理后的圖像,這里為了演示方便,我將圖片顯示在頁(yè)面中了
bitmap.Save(System.Web.HttpContext.Current.Server.MapPath("/" + "aa.jpg"), ImageFormat.Jpeg); //保存到磁盤(pán)上
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技術(shù)C# 添加文字水印類(lèi)代碼,轉(zhuǎn)載需保留來(lái)源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 狂躁美女BBBBBB视频 | 久久精品中文字幕 | 中文国产乱码在线人妻一区二区 | 99久久久国产精品免费蜜臀 | 国产色婷婷亚洲99精品 | 啊轻点灬大JI巴又大又粗 | 果冻传媒2021精品影视 | 十八禁啪啦啪漫画 | 91精品国产91热久久p | 亚洲国产货青视觉盛宴 | 免费毛片播放 | 观看免费做视频 | ass亚洲熟妇毛耸耸pics | 女人久久WWW免费人成看片 | 久久国产精品免费网站 | 飘雪在线观看免费完整版 | 一二三四在线观看高清电视剧 | 欧美亚洲国产手机在线有码 | 色噜噜狠狠一区二区三区 | www.97干| 精品国产在线观看福利 | 无修肉动漫在线观看影片 | 超碰人人澡人人胔 | 午夜办公室在线观看高清电影 | 日本G奶乳液汁 | 男人把女人桶到爽免费看视频 | 国产欧美日韩综合精品一区二区 | 精品无码国产自产在线观看水浒传 | 国产精品亚洲精品久久品 | 伊人情涩网 | 人人爽久久久噜噜噜丁香AV | 11 13加污女qq看他下面 | 国产在线观看99 | 亚洲伊人精品 | 俄罗斯女人Z0ZOZO | 老师你下面好紧夹死了 | 巨黄的肉辣文np | 无码日本亚洲一区久久精品 | 久久久97人妻无码精品蜜桃 | 国产精品久久久久久久久久久 | 一边啪啪的一边呻吟声口述 |