public virtual void MakeDeviceCmykNullColorValuesTest() { PdfColorSpace colorSpace = PdfColorSpace.MakeColorSpace(PdfName.DeviceCMYK); Color color = Color.MakeColor(colorSpace); NUnit.Framework.Assert.IsTrue(color is DeviceCmyk); NUnit.Framework.Assert.AreEqual(new float[] { 0.0f, 0.0f, 0.0f, 1.0f }, color.GetColorValue()); }
public virtual void MakeDeviceCmykTest() { float[] colorValues = new float[] { 0.7f, 0.5f, 0.1f, 0.3f }; PdfColorSpace colorSpace = PdfColorSpace.MakeColorSpace(PdfName.DeviceCMYK); Color color = Color.MakeColor(colorSpace, colorValues); NUnit.Framework.Assert.IsTrue(color is DeviceCmyk); NUnit.Framework.Assert.AreEqual(colorValues, color.GetColorValue()); }
public Color ProcessColorInfo(iText.Kernel.Colors.Color color) { if (color.GetColorSpace() is PdfDeviceCs.Cmyk) { color = iText.Kernel.Colors.Color.ConvertCmykToRgb((DeviceCmyk)color); } if (color.GetNumberOfComponents() == 1) { return(new Color((int)color.GetColorValue()[0])); } if (color.GetNumberOfComponents() == 3) { return(new Color(color.GetColorValue()[0], color.GetColorValue()[1], color.GetColorValue()[2])); } return(null); // todo handle }
public virtual void MakeIndexedNullColorValuesTest() { PdfArray indexed = new PdfArray(); indexed.Add(PdfName.Indexed); indexed.Add(new PdfArray()); indexed.Add(null); indexed.Add(null); PdfColorSpace colorSpace = PdfColorSpace.MakeColorSpace(indexed); Color color = Color.MakeColor(colorSpace); NUnit.Framework.Assert.IsTrue(color is Indexed); NUnit.Framework.Assert.AreEqual(new float[] { 0.0f }, color.GetColorValue()); }
public virtual void MakeDeviceNNullColorValuesTest() { PdfArray deviceN = new PdfArray(); deviceN.Add(PdfName.DeviceN); deviceN.Add(new PdfArray()); deviceN.Add(null); deviceN.Add(null); PdfColorSpace colorSpace = PdfColorSpace.MakeColorSpace(deviceN); Color color = Color.MakeColor(colorSpace); NUnit.Framework.Assert.IsTrue(color is DeviceN); NUnit.Framework.Assert.AreEqual(new float[] { }, color.GetColorValue()); }
public virtual void MakeLabNullColorValuesTest() { PdfDictionary dictionary = new PdfDictionary(); dictionary.Put(PdfName.Gamma, new PdfNumber(2.2)); PdfArray calLab = new PdfArray(); calLab.Add(PdfName.Lab); calLab.Add(dictionary); PdfColorSpace colorSpace = PdfColorSpace.MakeColorSpace(calLab); Color color = Color.MakeColor(colorSpace); NUnit.Framework.Assert.IsTrue(color is Lab); NUnit.Framework.Assert.AreEqual(new float[] { 0.0f, 0.0f, 0.0f }, color.GetColorValue()); }
protected void WriteColourSetting(XmlTextWriter xml, iText.Kernel.Colors.Color iTextColour, String name) { if (iTextColour.GetColorSpace().ToString() == "iText.Kernel.Pdf.Colorspace.PdfDeviceCs+Cmyk") { MessageBox.Show("Wrong Colour Space", "Not SUpported", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { float[] float_rgb = iTextColour.GetColorValue(); int r = Convert.ToInt32(Math.Round(255 * float_rgb[0])); int g = Convert.ToInt32(Math.Round(255 * float_rgb[1])); int b = Convert.ToInt32(Math.Round(255 * float_rgb[2])); String attribute = r.ToString() + "," + g.ToString() + "," + b.ToString(); xml.WriteAttributeString(name, attribute); } }
public virtual void MakeCalRgbTest() { PdfDictionary dictionary = new PdfDictionary(); dictionary.Put(PdfName.Gamma, new PdfNumber(2.2)); PdfArray calRgb = new PdfArray(); calRgb.Add(PdfName.CalRGB); calRgb.Add(dictionary); PdfColorSpace colorSpace = PdfColorSpace.MakeColorSpace(calRgb); float[] colorValues = new float[] { 0.7f, 0.5f, 0.1f }; Color color = Color.MakeColor(colorSpace, colorValues); NUnit.Framework.Assert.IsTrue(color is CalRgb); NUnit.Framework.Assert.AreEqual(colorValues, color.GetColorValue()); }
public PatternColor(PdfPattern.Tiling uncoloredPattern, Color color) : this(uncoloredPattern, color.GetColorSpace(), color.GetColorValue()) { }