Exemplo n.º 1
0
 /// <summary>
 ///     文字水印
 /// </summary>
 /// <param name="pic">原始图片</param>
 /// <param name="text">水印文字</param>
 /// <param name="place">水印位置</param>
 /// <param name="fontfamily">文字字体</param>
 /// <param name="fontsize">文字大小</param>
 /// <param name="fontcolor">文字颜色</param>
 public static void Mark(string pic, string text, MarkPlace place, string fontfamily, int?fontsize, Brush fontcolor)
 {
     using (Image txt = ToPicture(text, fontfamily, fontsize, fontcolor))
     {
         Mark(pic, txt, place);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 ///     图片水印
 /// </summary>
 /// <param name="pic">原始图片</param>
 /// <param name="markImagePath">水印路径</param>
 /// <param name="place">水印位置</param>
 public static void Mark(string pic, string markImagePath, MarkPlace place)
 {
     using (var mark = Image.FromFile(markImagePath))
     {
         Mark(pic, mark, place);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        ///     水印
        /// </summary>
        /// <param name="pic">原始图片</param>
        /// <param name="markImage">水印</param>
        /// <param name="place">水印位置</param>
        public static void Mark(string pic, Image markImage, MarkPlace place)
        {
            pic = Files.GetMapPath(pic);

            int y;
            var x = y = 0;

            using (var image = Image.FromFile(pic))
            {
                switch (place)
                {
                case MarkPlace.RightBottom:
                    x = image.Width - markImage.Width - 2;
                    y = image.Height - markImage.Height - 2;
                    break;

                case MarkPlace.LeftBottom:
                    x = 12;
                    y = image.Height - markImage.Height - 12;
                    break;

                case MarkPlace.LeftTop:
                    x = y = 12;
                    break;

                case MarkPlace.RightTop:
                    x = image.Width - markImage.Width - 12;
                    y = 12;
                    break;

                case MarkPlace.Center:
                    x = (image.Width - markImage.Width) / 2;
                    y = (image.Height - markImage.Height) / 2;
                    break;
                }
            }
            Mark(pic, markImage, x, y);
            markImage.Dispose();
        }
Exemplo n.º 4
0
 /// <summary>
 ///     文字水印
 /// </summary>
 /// <param name="pic">原始图片</param>
 /// <param name="text">水印文字</param>
 /// <param name="place">水印位置</param>
 /// <param name="fontfamily">文字字体</param>
 /// <param name="fontsize">文字大小</param>
 /// <param name="fontcolor">文字颜色</param>
 public static void Mark(string pic, string text, MarkPlace place, string fontfamily, int? fontsize, Brush fontcolor)
 {
     using (Image txt = ToPicture(text, fontfamily, fontsize, fontcolor)) { Mark(pic, txt, place); }
 }
Exemplo n.º 5
0
 /// <summary>
 ///     图片水印
 /// </summary>
 /// <param name="pic">原始图片</param>
 /// <param name="markImagePath">水印路径</param>
 /// <param name="place">水印位置</param>
 public static void Mark(string pic, string markImagePath, MarkPlace place)
 {
     using (var mark = Image.FromFile(markImagePath)) { Mark(pic, mark, place); }
 }
Exemplo n.º 6
0
 /// <summary>
 ///     水印
 /// </summary>
 /// <param name="pic">原始图片</param>
 /// <param name="markImage">水印</param>
 /// <param name="place">水印位置</param>
 public static void Mark(string pic, Image markImage, MarkPlace place)
 {
     int y;
     var x = y = 0;
     using (var image = Image.FromFile(pic))
     {
         switch (place)
         {
             case MarkPlace.RightBottom:
                 x = image.Width - markImage.Width - 2;
                 y = image.Height - markImage.Height - 2;
                 break;
             case MarkPlace.LeftBottom:
                 x = 12;
                 y = image.Height - markImage.Height - 12;
                 break;
             case MarkPlace.LeftTop:
                 x = y = 12;
                 break;
             case MarkPlace.RightTop:
                 x = image.Width - markImage.Width - 12;
                 y = 12;
                 break;
             case MarkPlace.Center:
                 x = (image.Width - markImage.Width) / 2;
                 y = (image.Height - markImage.Height) / 2;
                 break;
         }
     }
     Mark(pic, markImage, x, y);
     markImage.Dispose();
 }