Resizes an image to the given dimensions.
Inheritance: IGraphicsProcessor
        public void TestResizeRegex()
        {
            const string Querystring = "width=300";
            ResizeLayer expected = new ResizeLayer(new Size(300, 0));

            Resize resize = new Resize();

            resize.MatchRegexIndex(Querystring);
            ResizeLayer actual = resize.DynamicParameter;

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Resizes the current image to the given dimensions.
        /// </summary>
        /// <param name="resizeLayer">
        /// The <see cref="ResizeLayer"/> containing the properties required to resize the image.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Resize(ResizeLayer resizeLayer)
        {
            if (this.ShouldProcess)
            {
                Dictionary<string, string> resizeSettings = new Dictionary<string, string>
                {
                    { "MaxWidth", resizeLayer.Size.Width.ToString("G") },
                    { "MaxHeight", resizeLayer.Size.Height.ToString("G") }
                };

                Resize resize = new Resize { DynamicParameter = resizeLayer, Settings = resizeSettings };
                this.CurrentImageFormat.ApplyProcessor(resize.ProcessImage, this);
            }

            return this;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Resizes the current image to the given dimensions.
        /// </summary>
        /// <param name="size">
        /// The <see cref="T:System.Drawing.Size"/> containing the width and height to set the image to.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Resize(Size size)
        {
            if (this.ShouldProcess)
            {
                int width = size.Width;
                int height = size.Height;

                var resizeSettings = new Dictionary<string, string> { { "MaxWidth", width.ToString("G") }, { "MaxHeight", height.ToString("G") } };

                Resize resize = new Resize { DynamicParameter = new Size(width, height), Settings = resizeSettings };

                this.Image = resize.ProcessImage(this);
            }

            return this;
        }