日期:2014-05-17  浏览次数:20906 次

c#批量给图片添加水印,
想做一个小工具!批量给图片加上自己的透明图片水印和透明文字,求教.
已经创建了一个带透明的png图片作为水印.如何合并到背景图片上.?
求给代码和思路.谢谢
c# 图片 bitmap graphics

------解决方案--------------------
原来写的wpf的打水印的 楼主可以借鉴下


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