示例#1
0
        /// <summary>
        /// Tints the current image with the given color.
        /// </summary>
        /// <param name="color">
        /// The <see cref="T:System.Drawing.Color"/> to tint the image with.
        /// </param>
        /// <returns>
        /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class.
        /// </returns>
        public ImageFactory Tint(Color color)
        {
            if (this.ShouldProcess)
            {
                Tint tint = new Tint { DynamicParameter = color };
                this.CurrentImageFormat.ApplyProcessor(tint.ProcessImage, this);
            }

            return this;
        }
        public void TestTintRegex()
        {
            const string HexQuerystring = "tint=6aa6cc";
            const string RgbaQuerystring = "tint=106,166,204,255";
            Color expectedHex = ColorTranslator.FromHtml("#" + "6aa6cc");
            Color expectedRgba = Color.FromArgb(255, 106, 166, 204);

            Tint tint = new Tint();
            tint.MatchRegexIndex(HexQuerystring);
            Color actualHex = tint.DynamicParameter;
            Assert.AreEqual(expectedHex, actualHex);

            tint = new Tint();
            tint.MatchRegexIndex(RgbaQuerystring);
            Color actualRgba = tint.DynamicParameter;
            Assert.AreEqual(expectedRgba, actualRgba);
        }