/// <summary>
/// 生成水印,可按左上、左下、右上、右下、居中、透明度生成文件,只对jpeg或jpg格式有效! /// </summary> /// <param name="sourceFile">底图</param> /// <param name="waterMarkFile">水印图</param> /// <param name="saveFile">要保存的文件</param> /// <param name="local">位置:左上(1)、左下(2)、右上(3)、右下(4)、居中(5)</param> /// <param name="alpha">透明度(1-100)</param> /// <returns>bool,是否成功</returns> public static bool MakeWaterImage(string sourceFile,string waterMarkFile,string saveFile,int local,int alpha) { bool result; if( !File.Exists(sourceFile) || !File.Exists(waterMarkFile)) //如果源图或水印图不存在 return false; FileInfo fi = new FileInfo(sourceFile); //判断文件类型是否合法 if(fi.Extension.ToLower()!=".jpg" & fi.Extension.ToLower()!=".jpeg") return false; try { //原图 Bitmap sImage = new Bitmap(sourceFile); int sWidth = sImage.Width; int sHeight = sImage.Height; //水印图 Bitmap wImage = new Bitmap(waterMarkFile); int wWidth = wImage.Width; int wHeight = wImage.Height; //make Graphics. //校验透明度 |