【问题标题】:Can i add watermark on a series of pictures?我可以在一系列图片上添加水印吗?
【发布时间】:2010-06-14 21:32:04
【问题描述】:

我有大量图片,我想通过在它们上添加水印来“保护”它们。有什么方法可以使用 vb.net 或 C# 添加水印?

【问题讨论】:

    标签: c# vb.net image-processing jpeg watermark


    【解决方案1】:
    public void AddWatermark(string filename, string watermarkText, Stream outputStream) {
        Bitmap bitmap = Bitmap.FromFile(filename);
        Font font = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Pixel);
        Color color = Color.FromArgb(10, 0, 0, 0); //Adds a black watermark with a low alpha value (almost transparent).
        Point atPoint = new Point(100, 100); //The pixel point to draw the watermark at (this example puts it at 100, 100 (x, y)).
        SolidBrush brush = new SolidBrush(color);
    
        Graphics graphics = null;
        try {
            graphics = Graphics.FromImage(bitmap);
        } catch {
            Bitmap temp = bitmap;
            bitmap = new Bitmap(bitmap.Width, bitmap.Height);
            graphics = Graphics.FromImage(bitmap);
            graphics.DrawImage(temp, new Rectangle(0, 0, bitmap.Width, bitmap.Height), 0, 0, bitmap.Width, bitmap.Height, GraphicsUnit.Pixel);
            temp.Dispose();
        }
    
        graphics.DrawString(text, font, brush, atPoint);
        graphics.Dispose();
    
        bitmap.Save(outputStream);
    }
    

    【讨论】:

      【解决方案2】:

      【讨论】:

        【解决方案3】:

        This blog post 承诺:

        本文将描述一种构建简单水印实用程序的方法,该实用程序可用于向任何受支持的图像文件格式添加水印。生成的应用程序应允许用户将任何支持的图像文件格式打开到可滚动的图片框中,定义要应用为水印的文本(提供默认版本),设置水印的字体和颜色,定义水印的不透明度,以确定水印是出现在图像的顶部还是底部,并在将水印保存到图像之前进行预览。

        它应该提供一个很好的起点。

        【讨论】:

          猜你喜欢
          • 2017-07-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多