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


C# WebImage.AddImageWatermark方法代码示例

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


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

示例1: Upload

 public ActionResult Upload(int photoAlbumId, IEnumerable<HttpPostedFileBase> images)
 {
     if (images != null && images.All(i => i != null))
     {
         foreach (var image in images)
         {
             var webImage = new WebImage(image.InputStream) { FileName = image.FileName };
             webImage = webImage.AddImageWatermark("~/Content/Images/Watermark96.png");
             ImagesManager.UploadImage(webImage, Path.Combine("PhotoAlbum", photoAlbumId.ToString()), true, 120, 120, true);
         }
         TempData["Result"] = Resource.ChangesSaved;
     }
     else
     {
         TempData["Result"] = Resource.NoImagesChosen;
     }
     return RedirectToAction("Details", "PhotoAlbum", new { id = photoAlbumId });
 }
开发者ID:Yankovsky,项目名称:Shamrock,代码行数:18,代码来源:PhotoController.cs

示例2: Index

        public ActionResult Index(HttpPostedFileBase arquivo)
        {
            if (ModelState.IsValid)
            {
                if (arquivo != null)
                {
                    if (arquivo.ContentLength > (1024 * 1024))
                    {
                        ModelState.AddModelError("arquivo", "O tamanho do arquivo não pode ser maior que 1Mb");
                        return View();
                    }

                    var supportedTypes = new[] { "jpg", "jpeg", "png" };

                    var fileExt = Path.GetExtension(arquivo.FileName).Substring(1);

                    if (!supportedTypes.Contains(fileExt.ToLower()))
                    {
                        ModelState.AddModelError("arquivo",
                                                 "Tipo de arquivo invalido, use somente arquivos jpg, jpeg ou png");
                        return View();
                    }

                    //var fileName = Path.GetFileName(arquivo.FileName);//Nome Original do arquivo
                    var fileName = Guid.NewGuid().ToString() + "." + fileExt;//Nome unico

                    var path = Path.Combine(Server.MapPath("~/Content/Uploads"), fileName);

                    //arquivo.SaveAs(path); //somente se não for editar a foto, como no codigo abaixo

                    WebImage imagem = new WebImage(arquivo.InputStream);
                    imagem.Resize(350, 350);
                    //imagem.AddTextWatermark("Cleyton Ferrari");
                    imagem.AddImageWatermark("Content/Uploads/logo.png", 50, 50, "Right", "Bottom", 50, 2);
                    //imagem.Crop(100, 100, 100, 100);
                    imagem.FlipHorizontal();
                    imagem.Save(path);

                    ViewBag.imagem = "Content/Uploads/" + fileName;
                }
            }
            return View();
        }
开发者ID:JhonnyGoncalves,项目名称:UploadSimplesEmAspMVC,代码行数:43,代码来源:HomeController.cs

示例3: GetFileInternal

        private ActionResult GetFileInternal(string type, string url, int width = 0, int height = 0)
        {
            url = url.Replace("&#47;", "/");

            if (!this._fileService.CheckAccessFile(url))
            {
                this.Response.StatusCode = 401;
                return new HttpUnauthorizedResult();
            }

            string path = null;

            if (width > 0 && height > 0)
            {
                path = this._imageConverter.GetThumbPath(url, width, height);
                var pathParts = path.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
                url = pathParts.Last();
                path = string.Format("/{0}/", Web.Helpers.GetVirtualPath(string.Join("\\", pathParts.Take(pathParts.Length - 1))));
            }
            else
            {
                path = this.Request.Url.Segments.Contains(string.Format("{0}/", CmsConstants.SECURE)) ? string.Format("~/Content/{0}/{1}/", type, CmsConstants.SECURE) : string.Format("~/Content/{0}/", type);
            }

            // Todo: logic te determine which images should be watermarked. Use an event?
            if (false)
            {
                var webImage = new WebImage(path);
                string waterMarkPath = string.Format("{0}{1}", Server.MapPath("~"), StrixCms.Config.Files.WaterMarkPath.Replace('/', '\\'));
                webImage.AddImageWatermark(waterMarkPath);
                return this.File(webImage.GetBytes(), MimeMapping.GetMimeMapping(url));
            }

            return this.File(this.Server.MapPath(path) + url, MimeMapping.GetMimeMapping(url));
        }
开发者ID:StrixIT,项目名称:StrixIT.Platform.Modules.Cms,代码行数:35,代码来源:FileController.cs

示例4: Logo

        public static void Logo(string name, string diretorio, List<PosicaoLogo> posicaoLogo)
        {
            if (posicaoLogo.Any())
            {
                var pathImagem = MontaPath(diretorio, name);
                var imagem = new WebImage(pathImagem);

                foreach (var pLogo in posicaoLogo)
                {
                    //Todo: Tirar o acesso ao bando daqui
                    var nomeLogo = Fabrica.LogoAplicacaoMongo().ListarPorId(pLogo.IdLogo).Imagem;

                    //Carrega o logo e redimenciona para 33% do tamanho da imagem
                    var logo = new WebImage(MontaPath("Logo", nomeLogo)).Resize(imagem.Width / 3, imagem.Height / 3);
                    imagem.AddImageWatermark(logo, logo.Width, logo.Height, pLogo.PosicaoHorizontal, pLogo.PosicaoVertical, 90, 0);
                }

                imagem.Save(pathImagem);

            }
        }
开发者ID:josuecorrea,项目名称:Eva,代码行数:21,代码来源:ImagemHelper.cs


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