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


C# WebImage.Write方法代码示例

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


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

示例1: Thumbnail

        public ActionResult Thumbnail(string id)
        {
            var repository = new TagRepository();
            var tag = repository.GetTag(id);
            var photoList = repository.GetPhotoList(id);

            if (tag != null && photoList.Count > 0)
            {
                using (MultiThumbnailGenerator generator = new MultiThumbnailGenerator())
                {
                    foreach (var photo in photoList)
                    {
                        using (var imageStream = new System.IO.MemoryStream(photo.FileContents))
                        {
                            using (var image = System.Drawing.Image.FromStream(imageStream))
                            {
                                generator.AddImage(image);
                            }
                        }
                    }

                    using (var outStream = new System.IO.MemoryStream())
                    {
                        generator.WritePngToStream(outStream);
                        var image = new WebImage(outStream);
                        image.Write();
                    }
                }

                return null;
            }

            return Redirect("~/Content/Images/gallery-empty.png");
        }
开发者ID:csell5,项目名称:Demos,代码行数:34,代码来源:TagController.cs

示例2: GetImage

        public void GetImage(string horizontalFlip="", string verticalFlip="",
                            string rotateLeft="", string rotateRight="")
        {
            var imagePath = Server.MapPath("~/images/bunny-peanuts.jpg");
            var image = new WebImage(imagePath);

            if (!string.IsNullOrWhiteSpace(verticalFlip))
                image = image.FlipVertical();
            if (!string.IsNullOrWhiteSpace(horizontalFlip))
                image = image.FlipHorizontal();
            if (!string.IsNullOrWhiteSpace(rotateLeft))
                image = image.RotateLeft();
            if (!string.IsNullOrWhiteSpace(rotateRight))
                image = image.RotateRight();

            image.Write();
        }
开发者ID:Wangweizhou,项目名称:Visual-Studio-Experiments,代码行数:17,代码来源:ImageWorkshopController.cs

示例3: GetResizeImage

        //---------------------------------------------------------------------------------------------------

        //--Изменят размер и обрезает изображение или просто изменяет размер---------------------------------
        public void GetResizeImage(int id, int rWidth = 320, int rHeight = 320, int cWidth = 0, int cHeight = 0)
        {
            ImageDetails img = repository.Load(id);
            WebImage wbImage = new WebImage(img.image);
            wbImage.Resize(rWidth, rHeight); //--изменяем размер картинки--

            int h = wbImage.Height, w = wbImage.Width;

            wbImage.Crop(cHeight, cWidth, cHeight, cWidth); //--обрезаем картинку--
            wbImage.FileName = img.title + ".jpg";

            wbImage.Write();
        }
开发者ID:ilnur-slv,项目名称:ilnur-slv.ru,代码行数:16,代码来源:ImageController.cs

示例4: GetCurrentImage

        public void GetCurrentImage(string key)
        {
            WebImage wi = new WebImage(_worker.FileRepository.RetrieveAttachment(key));

            wi.Write();
        }
开发者ID:larswise,项目名称:rCMS,代码行数:6,代码来源:FileController.cs

示例5: Thumbnail

        public ActionResult Thumbnail(int id)
        {
            var db = new PhotoGalleryRepository();

            var gallery = db.GetGallery(id);
            if (gallery == null)
            {
                return HttpNotFound();
            }

            var photos = db.GetTopPhotosForGallery(id);
            if (photos.Count == 0)
            {
                return File(Server.MapPath("~/Content/Images/gallery-empty.png"), "image/jpeg");
            }

            using (var generator = new MultiThumbnailGenerator())
            {
                foreach (var photo in photos)
                {
                    using (var imageStream = new MemoryStream(photo.FileContents))
                    {
                        using (var image = System.Drawing.Image.FromStream(imageStream))
                        {
                            generator.AddImage(image);
                        }
                    }
                }
                using (var outStream = new MemoryStream())
                {
                    generator.WritePngToStream(outStream);
                    var image = new WebImage(outStream);
                    image.Write();

                    return null;
                }
            }
        }
开发者ID:csell5,项目名称:Demos,代码行数:38,代码来源:GalleryController.cs


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