当前位置: 首页>>代码示例>>C#>>正文


C# WebImage.AddTextWatermark方法代码示例

本文整理汇总了C#中System.Web.Helpers.WebImage.AddTextWatermark方法的典型用法代码示例。如果您正苦于以下问题:C# WebImage.AddTextWatermark方法的具体用法?C# WebImage.AddTextWatermark怎么用?C# WebImage.AddTextWatermark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Helpers.WebImage的用法示例。


在下文中一共展示了WebImage.AddTextWatermark方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddWaterMark

 public static byte[] AddWaterMark(string filePath, string text)
 {
     using (var img = System.Drawing.Image.FromFile(filePath))
     {
         using (var memStream = new MemoryStream())
         {
             using (var bitmap = new Bitmap(img)) // to avoid GDI+ errors
             {
                 bitmap.Save(memStream, ImageFormat.Png);
                 var content = memStream.ToArray();
                 var webImage = new WebImage(memStream);
                 webImage.AddTextWatermark(text, verticalAlign: "Top", horizontalAlign: "Left", fontColor: "Brown");
                 return webImage.GetBytes();
             }
         }
     }
 }
开发者ID:rabbal,项目名称:AspNetMVCNTierTemp,代码行数:17,代码来源:ImageManage.cs

示例2: ShowGuidWithWatermark

        public ActionResult ShowGuidWithWatermark(string guid, string path, string width, string height)
        {
            int intWidth = 0;
            int intHeight = 0;

            if (!int.TryParse(width, out intWidth))
            {
                return null;
            }

            if (!int.TryParse(height, out intHeight))
            {
                return null;
            }

            if (string.IsNullOrWhiteSpace(guid) || string.IsNullOrWhiteSpace(path))
            {
                return null;
            }

            string photoName = "";
            string coordinate = "";

            var dc = new DbWithBasicFunction();
            var db = dc.db;

            if (path.ToLower() == "gallery")
            {
                var galleryItem = db.tbl_gallery.Where(a => a.guid == guid).FirstOrDefault();

                if (galleryItem == null)
                {
                    return null;
                }

                photoName = galleryItem.photo;
                coordinate = galleryItem.photoCoordinate;

            }

            var item = getFileCoordinated(photoName, coordinate, path);

            if (item != null)
            {
                var settings = new ResizeSettings();

                int widthInt = int.Parse(width);
                int heightInt = int.Parse(height);

                settings.Width = widthInt;
                settings.Height = heightInt;
                settings.Mode = FitMode.Stretch;

                WebImage waterMarkImage;

                using (MemoryStream st = new MemoryStream())
                {

                    ImageBuilder.Current.Build(item.First().Key, st, settings);
                    st.Position = 0;

                    waterMarkImage = new WebImage(st);

                }

                waterMarkImage.AddTextWatermark("www.titizkromaksesuar.com", fontColor: "#ffe27b", fontSize: 10, verticalAlign: "Middle", opacity: 60);

                return File(waterMarkImage.GetBytes(), item.First().Value);

            }
            else
            {
                return null;
            }
        }
开发者ID:erkanAslanel,项目名称:titizOto,代码行数:75,代码来源:ImageShowController.cs

示例3: WaterMark

        private Byte[] WaterMark(Stream s,string color)
        {
            MemoryStream str = new MemoryStream();
            System.Web.Helpers.WebImage webimg = new System.Web.Helpers.WebImage(s);
            String wm = WebSecurity.CurrentUserName;
            webimg.AddTextWatermark(wm, color, 16, "Regular", "Microsoft Sans Serif", "Right", "Bottom", 50, 10);

            return webimg.GetBytes();
        }
开发者ID:BurileanuDaniel,项目名称:photoinvasion,代码行数:9,代码来源:AlbumController.cs

示例4: ResizeImageAndSaveToDisk

        /// <summary>
        /// Resizes an image and saves it to disk.
        /// </summary>
        /// <param name="webImage">Web image object</param>
        /// <param name="image">The image object</param>
        private static string ResizeImageAndSaveToDisk(WebImage webImage)
        {
            webImage = webImage.AddTextWatermark(".NET Jumpstart");

            // Resize image with web image helper
            webImage = webImage.Resize(1024, 768, true, true);

            // Create random name
            var guid = Guid.NewGuid();
            var extension = Path.GetExtension(webImage.FileName);

            // Set filename and save to disk
            string fileName = string.Format("{0}{1}", guid, extension);
            var path = GetLocalFilePath(fileName);
            webImage.Save(path);

            return fileName;
        }
开发者ID:danielbeckmann,项目名称:DotNETJumpStart,代码行数:23,代码来源:ImageUtility.cs

示例5: GetResource

        public ActionResult GetResource(Guid id, int? width, int? height, bool? noSource)
        {
            //get the resource.
            var res = db.Resources.SingleOrDefault(r => r.ID == id);
            if (res == null) return HttpNotFound("That resource cannot be found.");

            var path = Path.Combine(Server.MapPath("~/ResourceUploads"), id.ToString());
            var stream = new FileStream(path, FileMode.Open);
            if (stream.Length == 0) throw new HttpException(503, "An internal server error occured whilst fetching the resource.");

            Stream outputStream = stream;

            if (res.Type.StartsWith("image"))
            {
                var image = new WebImage(stream);

                if (width.HasValue && height.HasValue)
                {
                    //Resize!
                    image.Resize(width.Value, height.Value, true, true);
                }

                if (!string.IsNullOrWhiteSpace(res.Source) && noSource != true)
                {
                    image.AddTextWatermark(res.Source, "#" + ((res.SourceTextColor == null) ? "FFFFFF" : res.SourceTextColor.Value));
                }

                outputStream = new MemoryStream(image.GetBytes());
            }

            stream.Close();

            return File(outputStream, res.Type);
        }
开发者ID:JamesP2,项目名称:ReviewSite,代码行数:34,代码来源:CoreController.cs


注:本文中的System.Web.Helpers.WebImage.AddTextWatermark方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。