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

C# 添加圖片水印類(lèi)實(shí)現(xiàn)代碼

復(fù)制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.IO;
using System.Drawing.Imaging;
using System.Web;
using System.Drawing.Drawing2D;
using System.Reflection;
namespace Chen
{
public class warterPic
{
/// <summary>
/// 給圖片上水印
/// </summary>
/// <param name="filepath">原圖片地址</param>
/// <param name="waterfile">水印圖片地址</param>
///
public void markwater(string filepath, string waterfile)
{
//gif不水印
int i = filepath.LastIndexOf(".");
string ex = filepath.Substring(i, filepath.Length - i);
if (string.Compare(ex, ".gif", true) == 0)
{
return;
}
string modifyimagepath = filepath;//修改的圖像路徑
int lucencypercent = 25;
Image modifyimage = null;
Image drawedimage = null;
Graphics g = null;
try
{
//建立圖形對(duì)象
modifyimage = Image.FromFile(modifyimagepath, true);
drawedimage = Image.FromFile(waterfile, true);
g = Graphics.FromImage(modifyimage);
//獲取要繪制圖形坐標(biāo)
int x = modifyimage.Width - drawedimage.Width;
int y = modifyimage.Height - drawedimage.Height; //設(shè)置顏色矩陣
float[][] matrixitems ={ new float[] { 1, 0, 0, 0, 0 }, new float[] { 0, 1, 0, 0, 0 }, new float[] { 0, 0, 1, 0, 0 }, new float[] { 0, 0, 0, (float)lucencypercent / 100f, 0 }, new float[] { 0, 0, 0, 0, 1 } };
ColorMatrix colormatrix = new ColorMatrix(matrixitems);
ImageAttributes imgattr = new ImageAttributes();
imgattr.SetColorMatrix(colormatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); //繪制陰影圖像
g.DrawImage(drawedimage, new Rectangle(x, y, drawedimage.Width, drawedimage.Height), 10, 10, drawedimage.Width, drawedimage.Height, GraphicsUnit.Pixel, imgattr); //保存文件
string[] allowimagetype ={ ".jpg", ".gif", ".png", ".bmp", ".tiff", ".wmf", ".ico" };
FileInfo fi = new FileInfo(modifyimagepath);
ImageFormat imagetype = ImageFormat.Gif;
switch (fi.Extension.ToLower())
{
case ".jpg":
imagetype = ImageFormat.Jpeg;
break;
case ".gif":
imagetype = ImageFormat.Gif;
break;
case ".png":
imagetype = ImageFormat.Png;
break;
case ".bmp":
imagetype = ImageFormat.Bmp;
break;
case ".tif":
imagetype = ImageFormat.Tiff;
break;
case ".wmf":
imagetype = ImageFormat.Wmf;
break;
case ".ico":
imagetype = ImageFormat.Icon;
break;
default: break;
}
MemoryStream ms = new MemoryStream();
modifyimage.Save(ms, imagetype);
byte[] imgdata = ms.ToArray();
modifyimage.Dispose();
drawedimage.Dispose();
g.Dispose();
FileStream fs = null;
//File.Delete(modifyimagepath);
fs = new FileStream(modifyimagepath, FileMode.Create, FileAccess.Write);
if (fs != null)
{
fs.Write(imgdata, 0, imgdata.Length);
fs.Close();
}
}
finally
{
try
{
drawedimage.Dispose();
modifyimage.Dispose();
g.Dispose();
}
catch
{ }
}
}
}
}

AspNet技術(shù)C# 添加圖片水印類(lèi)實(shí)現(xiàn)代碼,轉(zhuǎn)載需保留來(lái)源!

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

主站蜘蛛池模板: 狠狠狠色丁香婷婷综合久久 | 午夜一级免费视频 | 国产精品一区二区亚瑟不卡 | 色综合久久综合网观看 | 一本色道久久综合一区 | 亚洲视频中文字幕在线观看 | 午夜国产理论 | 久久久久久电影 | 国产成人99久久亚洲综合精品 | 色狠狠一区| 性色无码AV久久蜜臀 | 芒果视频看片在线观看 | 国产亚洲精品成人a在线 | 奇米狠狠一区二区三区 | 快播黄色电影 | 国产极品美女视频福利 | 中国拍三a级的明星女 | 久久国产精品萌白酱免费 | 色欲AV精品一区二区入口 | 亚洲AV无码乱码A片无码蜜桃 | 国产精品无码亚洲网 | 妈妈的职业3完整版在线播放 | 果冻传媒色AV国产播放 | 亚洲国产成人爱AV在线播放丿 | 国产一区二区在线免费观看 | xx69欧美| 国内久久久久影院精品 | 国产精品悠悠久久人妻精品 | 羞羞在线观看 | 男男免费看| 人妻免费久久久久久久了 | 亚洲日本在线不卡二区 | 国产性色AV内射白浆肛交后入 | 久久中文字幕亚洲精品最新 | 国产精品免费一区二区三区四区 | 日韩欧美中文字幕在线二视频 | 美女张开让男生桶 | 亚洲AV永久无码精品澳门 | 国产AV天堂亚洲AV麻豆 | 成人国内精品久久久久影 | 被吊起玩弄的女性奴 |