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

C# 添加圖片水印類實現代碼

復制代碼 代碼如下:
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
{
//建立圖形對象
modifyimage = Image.FromFile(modifyimagepath, true);
drawedimage = Image.FromFile(waterfile, true);
g = Graphics.FromImage(modifyimage);
//獲取要繪制圖形坐標
int x = modifyimage.Width - drawedimage.Width;
int y = modifyimage.Height - drawedimage.Height; //設置顏色矩陣
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技術C# 添加圖片水印類實現代碼,轉載需保留來源!

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

主站蜘蛛池模板: 第一次玩老妇真实经历 | yellow在线观看免费高清的日本 | 亚洲成 人a影院青久在线观看 | 久久看片网 | 亚洲一区自拍高清亚洲精品 | 好男人视频免费高清在线观看www | 他揉捏她两乳不停呻吟口述 | 国产精品亚洲欧美一区麻豆 | free性欧美xxx狂欢 | 色-情-伦-理一区二区三区 | 无人区乱码区1卡2卡三卡在线 | 天美传媒在线观看完整高清 | 国产精品永久免费视频观看 | 成人18视频在线观看 | 777ZYZ玖玖资源站最稳定网址 | 伊人久久亚洲精品一区 | 一级毛片皇帝 宫女 | 国产欧美日韩精品a在线观看高清 | 成激人情在线影院920 | 黑人巨大交牲老太 | 久久se视频精品视频在线 | 无码任你躁久久久久久老妇双奶 | 亚洲精品国产熟女久久久 | 99精品国产高清自在线看超 | 后入内射国产一区二区 | 亚洲成A人片在线观看中文不卡 | 亚洲国产成人精品久久久久 | 亚洲国产在线精品第二剧情不卡 | 叔叔 电影完整版免费观看韩国 | 免费A级毛片无码无遮挡 | 国际老妇高清在线观看 | 日韩人妻精品久久日 | 人人听力网mp3下载 人人舔人人爱 | 久久99精品AV99果冻 | 久久99国产视频 | 第一福利视频网站在线 | 内射爽无广熟女亚洲 | 棉签和冰块怎么弄出牛奶视频 | 国产免费人成在线视频有码 | 雪恋电影完整版免费观看 | 真人做受120分钟免费看 |