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


C# ResizeSettings.Add方法代码示例

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


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

示例1: FileStorage

        public FileStorage(ISettings settings)
        {
            _settings = settings;
            
            _resizeSettings = new ResizeSettings {
                    MaxWidth = settings.ThumbnailSize,
                    MaxHeight = settings.ThumbnailSize, 
                    Format = "jpg"
                };
            _resizeSettings.Add("quality", ImageQuality);

            //create FullsizedImagesFolder & SmallImagesFolder subfolders
            string largeFilesFolder = Path.Combine(settings.ImagesLocalFolder, FullsizedImagesFolder);
            string smallFilesFolder = Path.Combine(settings.ImagesLocalFolder, SmallImagesFolder);

            if (!Directory.Exists(largeFilesFolder))
                Directory.CreateDirectory(largeFilesFolder);
            if (!Directory.Exists(smallFilesFolder))
                Directory.CreateDirectory(smallFilesFolder);
            
            _lastPhoto = Directory
                .GetFiles(largeFilesFolder, "*.jpg")
                .Select(i => int.Parse(Path.GetFileNameWithoutExtension(i).ToLower().Replace(".jpg", "")))
                .OrderByDescending(i => i)
                .FirstOrDefault();

            if (_lastPhoto < 1)
                _lastPhoto = 1;
        }
开发者ID:EgorBo,项目名称:CrossChat-Xamarin.Forms,代码行数:29,代码来源:FileStorage.cs

示例2: Generate

        //
        // GET: /Image/

        public FileResult Generate(string source, int width, int height)
        {
            string url = Uri.UnescapeDataString(source);
            HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
            HttpWebResponse httpWebReponse = (HttpWebResponse)httpWebRequest.GetResponse();
            Stream stream = httpWebReponse.GetResponseStream();

            var quality = 80;
            byte[] resized;
            using (var outStream = new MemoryStream())
            {
                var settings = new ResizeSettings
                {
                    Mode = FitMode.Crop,
                    Width = width,
                    Height = height,
                    Format = "jpg"
                };
                settings.Add("quality", quality.ToString());
                ImageBuilder.Current.Build(stream, outStream, settings);
                resized = outStream.ToArray();
            }

            stream.Dispose();

            return new FileStreamResult(new MemoryStream(resized, 0, resized.Length), "image/jpeg");
        }
开发者ID:agentvnod,项目名称:tfctvoldcode,代码行数:30,代码来源:ImageController.cs

示例3: ScaleAndSavePhotos

        private void ScaleAndSavePhotos(PhotoModel model, HttpRequestBase request)
        {
            var file = request.Files[0];
            string extension = Path.GetExtension(file.FileName);
            string filename = file.FileName;

            //Copied Image and add watermark.
            ResizeSettings settings = new ResizeSettings();
            settings.Add("format", "jpg");
            settings.Add("quality", "90");
            settings.Add("carve", "true");
            settings.Add("scale", "down");
            settings.Add("mode", "carve");
            if (model.Watermark)
            {
                settings.Add("watermark", "wm");
            }

            var path = Path.Combine(HttpContext.Current.Server.MapPath(string.Format("~/Albums/{0}", model.AlbumId)));
            if (Directory.Exists(path))
            {
                //thumb is 75x75
                //small is 240x159
                //medium is 500 x 332
                //large is 1024 x 680

                Image img = Image.FromStream(file.InputStream);

                //PropertyItem[] properties = img.PropertyItems;

                //foreach (PropertyItem prop in properties)
                //{

                //}

                bool vert = img.Height > img.Width;

                settings.Add("maxwidth", vert ? "680" : "1024");
                //settings.Add("maxheight", vert ? "1024" : "680");

                Bitmap copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
                copy.Save(Path.Combine(path, "Large\\" + filename));

                settings.Remove("maxwidth");
                //settings.Remove("maxheight");
                settings.Remove("watermark");
                settings.Add("maxwidth", vert ? "332" : "500");
                //settings.Add("maxheight", vert ? "500" : "332");
                copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
                copy.Save(Path.Combine(path, "Medium\\" + filename));

                settings.Remove("maxwidth");
                //settings.Remove("maxheight");
                settings.Remove("watermark");
                settings.Add("maxwidth", vert ? "200" : "301");
                //settings.Add("maxheight", vert ? "301" : "200");
                copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
                copy.Save(Path.Combine(path, "Small\\" + filename));

                settings.Remove("maxwidth");
                settings.Remove("maxwidth");
                settings.Remove("watermark");
                settings.Add("maxwidth", "75");
                settings.Add("maxheight", "75");
                copy = ImageResizer.ImageBuilder.Current.Build(img, settings, false);
                copy.Save(Path.Combine(path, "Thumb\\" + filename));

                file.SaveAs(Path.Combine(path, "Original\\" + filename));
            }
        }
开发者ID:janstadt,项目名称:anstadtfamily,代码行数:70,代码来源:AlbumService.cs


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