Example #1
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);
        }
Example #2
0
        public virtual void NotEqualsDifferentClassesTest()
        {
            float[]    colorValues = new float[] { 0.0f, 0.5f, 0.1f };
            Color      color1      = Color.MakeColor(PdfColorSpace.MakeColorSpace(PdfName.DeviceRGB), colorValues);
            DeviceCmyk cmyk        = new DeviceCmyk(0, 0, 0, 0);
            bool       result      = color1.Equals(cmyk);

            NUnit.Framework.Assert.IsFalse(result);
        }
Example #3
0
        /// <summary>
        /// Converts
        /// <see cref="DeviceCmyk">DeviceCmyk</see>
        /// color to
        /// <see cref="DeviceRgb">DeviceRgb</see>
        /// color
        /// </summary>
        /// <param name="cmykColor">the DeviceCmyk color which will be converted to DeviceRgb color</param>
        /// <returns>converted color</returns>
        public static DeviceRgb ConvertCmykToRgb(DeviceCmyk cmykColor)
        {
            float cyanComp    = 1 - cmykColor.GetColorValue()[0];
            float magentaComp = 1 - cmykColor.GetColorValue()[1];
            float yellowComp  = 1 - cmykColor.GetColorValue()[2];
            float blackComp   = 1 - cmykColor.GetColorValue()[3];
            float r           = cyanComp * blackComp;
            float g           = magentaComp * blackComp;
            float b           = yellowComp * blackComp;

            return(new DeviceRgb(r, g, b));
        }