日期:2014-05-17 浏览次数:20959 次
public class WatermarkHelper
{
string _waterImgPath;
BitmapSource _waterPic;
string _prefix = null;
// constructors
public WatermarkHelper(string waterImgFilePath, string prefix = null)
{
this._waterImgPath = waterImgFilePath;
this._waterPic = new BitmapImage(new Uri(this._waterImgPath));
if (prefix == null)
prefix = "";
this._prefix = prefix;
// this._result = false;
}
// public members
public void AddWatermark_SaveToDir(string inputFilePath, string outputDir)
{
if (!Directory.Exists(outputDir))
Directory.CreateDirectory(outputDir);
string output_filepath = Path.Combine(
outputDir,
string.Format("{0}{1}", this._prefix, Path.GetFileName(inputFilePath))
); // <-- use Path.Combine to prevent potential problems
// process
Process(inputFilePath, output_filepath);
}
public void AddWatermark_SaveToFile(string inputFilePath, string output_filepath) // <-- you see what i mean when i sa