Esempio n. 1
0
        /// <summary>
        /// Returns
        /// <see cref="DeviceCmyk">DeviceCmyk</see>
        /// color which is darker than given one
        /// </summary>
        /// <param name="cmykColor">the DeviceCmyk color to be made darker</param>
        /// <returns>darker color</returns>
        public static iText.Kernel.Colors.DeviceCmyk MakeDarker(iText.Kernel.Colors.DeviceCmyk cmykColor)
        {
            DeviceRgb rgbEquivalent = ConvertCmykToRgb(cmykColor);
            DeviceRgb darkerRgb     = DeviceRgb.MakeDarker(rgbEquivalent);

            return(ConvertRgbToCmyk(darkerRgb));
        }
Esempio n. 2
0
        public virtual void ConvertRgbToCmykTest()
        {
            DeviceCmyk cmyk = new DeviceCmyk(0, 0, 0, 0);
            DeviceRgb  rgb  = new DeviceRgb(255, 255, 255);

            NUnit.Framework.Assert.AreEqual(cmyk.colorValue, Color.ConvertRgbToCmyk(rgb).colorValue);
        }
Esempio n. 3
0
        public Legend AddLegend(String label, iText.Kernel.Colors.DeviceRgb colour)
        {
            Legend result = new Legend(label, colour);

            mLegends.Add(result);
            return(result);
        }
Esempio n. 4
0
        public virtual void GetRGBColorByUnsupportedNameTest()
        {
            String    colorName = "tangerine";
            DeviceRgb cmpRgb    = new DeviceRgb(0, 0, 0);
            DeviceRgb resultRgb = WebColors.GetRGBColor(colorName);

            NUnit.Framework.Assert.AreEqual(cmpRgb, resultRgb);
        }
Esempio n. 5
0
        public virtual void GetRGBColorBySupportedNameTest()
        {
            String    colorName = "violet";
            DeviceRgb cmpRgb    = new DeviceRgb(0xee, 0x82, 0xee);
            DeviceRgb resultRgb = WebColors.GetRGBColor(colorName);

            NUnit.Framework.Assert.AreEqual(cmpRgb, resultRgb);
        }
Esempio n. 6
0
        public virtual void ColorByAWTColorTest()
        {
            System.Drawing.Color color    = System.Drawing.Color.FromArgb(50, 100, 150);
            DeviceRgb            rgbColor = new DeviceRgb(color);

            float[] rgbColorValue = rgbColor.GetColorValue();
            NUnit.Framework.Assert.AreEqual(50f / 255, rgbColorValue[0], 0.0001);
            NUnit.Framework.Assert.AreEqual(100f / 255, rgbColorValue[1], 0.0001);
            NUnit.Framework.Assert.AreEqual(150f / 255, rgbColorValue[2], 0.0001);
        }
Esempio n. 7
0
        public virtual void MakeLighterTest()
        {
            DeviceRgb rgbColor       = new DeviceRgb(50, 100, 150);
            DeviceRgb darkerRgbColor = DeviceRgb.MakeLighter(rgbColor);
            // check the resultant darkness of RGB items with using this multiplier
            float multiplier = Math.Min(1f, 150f / 255 + 0.33f) / (150f / 255);

            NUnit.Framework.Assert.AreEqual(multiplier * (50f / 255), darkerRgbColor.GetColorValue()[0], 0.0001);
            NUnit.Framework.Assert.AreEqual(multiplier * (100f / 255), darkerRgbColor.GetColorValue()[1], 0.0001);
            NUnit.Framework.Assert.AreEqual(multiplier * (150f / 255), darkerRgbColor.GetColorValue()[2], 0.0001);
        }
Esempio n. 8
0
        private float GetSumOfColorValues(DeviceRgb deviceRgb)
        {
            float sum = 0;

            float[] values = deviceRgb.GetColorValue();
            for (int i = 0; i < values.Length; i++)
            {
                sum += values[i];
            }
            return(sum);
        }
Esempio n. 9
0
        /// <summary>
        /// Converts
        /// <see cref="DeviceRgb">DeviceRgb</see>
        /// color to
        /// <see cref="DeviceCmyk">DeviceCmyk</see>
        /// color
        /// </summary>
        /// <param name="rgbColor">the DeviceRgb color which will be converted to DeviceCmyk color</param>
        /// <returns>converted color</returns>
        public static DeviceCmyk ConvertRgbToCmyk(DeviceRgb rgbColor)
        {
            float redComp   = rgbColor.GetColorValue()[0];
            float greenComp = rgbColor.GetColorValue()[1];
            float blueComp  = rgbColor.GetColorValue()[2];
            float k         = 1 - Math.Max(Math.Max(redComp, greenComp), blueComp);
            float c         = (1 - redComp - k) / (1 - k);
            float m         = (1 - greenComp - k) / (1 - k);
            float y         = (1 - blueComp - k) / (1 - k);

            return(new DeviceCmyk(c, m, y, k));
        }
Esempio n. 10
0
        protected virtual void ReadColour(XmlTextReader xml, ref iText.Kernel.Colors.DeviceRgb iTextColour, String attributeName)
        {
            String colourString = xml.GetAttribute(attributeName);

            String[] values = colourString.Split(',');
            if (values.Length == 3)
            {
                int r = Convert.ToInt32(values[0]);
                int g = Convert.ToInt32(values[1]);
                int b = Convert.ToInt32(values[2]);
                iTextColour = new DeviceRgb(r, g, b);
            }
        }
Esempio n. 11
0
        public virtual void ColorByAWTColorConstantTest()
        {
            // RED
            DeviceRgb rgbColor = new DeviceRgb(System.Drawing.Color.Red);

            float[] rgbColorValue = rgbColor.GetColorValue();
            NUnit.Framework.Assert.AreEqual(1, rgbColorValue[0], 0.0001);
            NUnit.Framework.Assert.AreEqual(0, rgbColorValue[1], 0.0001);
            NUnit.Framework.Assert.AreEqual(0, rgbColorValue[2], 0.0001);
            // GREEN
            rgbColor      = new DeviceRgb(System.Drawing.Color.Lime);
            rgbColorValue = rgbColor.GetColorValue();
            NUnit.Framework.Assert.AreEqual(0, rgbColorValue[0], 0.0001);
            NUnit.Framework.Assert.AreEqual(1, rgbColorValue[1], 0.0001);
            NUnit.Framework.Assert.AreEqual(0, rgbColorValue[2], 0.0001);
            // BLUE
            rgbColor      = new DeviceRgb(System.Drawing.Color.Blue);
            rgbColorValue = rgbColor.GetColorValue();
            NUnit.Framework.Assert.AreEqual(0, rgbColorValue[0], 0.0001);
            NUnit.Framework.Assert.AreEqual(0, rgbColorValue[1], 0.0001);
            NUnit.Framework.Assert.AreEqual(1, rgbColorValue[2], 0.0001);
        }