天天躁日日躁狠狠躁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# 添加圖片水印類實現代碼,轉載需保留來源!

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

主站蜘蛛池模板: 国产色婷婷精品人妻蜜桃成熟时 | 亚洲国产免费观看视频 | 白人大战34厘米黑人BD | 日韩AV片无码一区二区三区不卡 | 国产不卡一卡2卡三卡4卡网站 | 久久大香线蕉综合爱 | 日本午夜精品一区二区三区电影 | 色婷婷综合激情中文在线 | 欧洲馒头大肥p | yellow在线中文| 中文字幕在线观看国产 | 97在线播放视频 | 国产成人在线视频播放 | 三级黄在线播放 | 嫩草影院久久国产精品 | 亚洲欧洲日本天天堂在线观看 | 久久青草影院 | 美女扣逼软件 | 24小时日本免费看 | 尤物久久99国产综合精品 | 久久精品国产亚洲AV未满十八 | 99免费在线观看 | c了瑜伽老师嗷嗷叫一节课视频 | 国产午夜福利片 | 日日AV夜夜添久久奶无码 | 大中国免费视频大全在线观看 | 高h乱np甄宓 | 99视频在线免费 | 午夜亚洲精品不卡在线 | 国产精品熟女人妻 | 中字幕久久久人妻熟女天美传媒 | 激情内射亚州一区二区三区爱妻 | 亚洲欧美中文字幕5发布 | 芭乐草莓樱桃丝瓜18岁大全 | 精品无码国产污污污免费网站2 | 英国video性精品高清最新 | 好男人WWW免费高清视频在线 | 男人的天堂黄色片 | 综合一区无套内射中文字幕 | 日韩大胆视频 | 岳打开双腿开始配合日韩视频 |