/// <summary>Makes a Color of certain color space and color value.</summary> /// <remarks> /// Makes a Color of certain color space and color value. /// If color value is set in null, all value components will be initialised with zeroes. /// </remarks> /// <param name="colorSpace">the color space to which the returned Color object relates</param> /// <param name="colorValue">the color value of the returned Color object</param> /// <returns>the created Color object.</returns> public static iText.Kernel.Colors.Color MakeColor(PdfColorSpace colorSpace, float[] colorValue) { iText.Kernel.Colors.Color c = null; bool unknownColorSpace = false; if (colorSpace is PdfDeviceCs) { if (colorSpace is PdfDeviceCs.Gray) { c = colorValue != null ? new DeviceGray(colorValue[0]) : new DeviceGray(); } else { if (colorSpace is PdfDeviceCs.Rgb) { c = colorValue != null ? new DeviceRgb(colorValue[0], colorValue[1], colorValue[2]) : new DeviceRgb(); } else { if (colorSpace is PdfDeviceCs.Cmyk) { c = colorValue != null ? new DeviceCmyk(colorValue[0], colorValue[1], colorValue[2], colorValue[3]) : new DeviceCmyk(); } else { unknownColorSpace = true; } } } } else { if (colorSpace is PdfCieBasedCs) { if (colorSpace is PdfCieBasedCs.CalGray) { PdfCieBasedCs.CalGray calGray = (PdfCieBasedCs.CalGray)colorSpace; c = colorValue != null ? new CalGray(calGray, colorValue[0]) : new CalGray(calGray); } else { if (colorSpace is PdfCieBasedCs.CalRgb) { PdfCieBasedCs.CalRgb calRgb = (PdfCieBasedCs.CalRgb)colorSpace; c = colorValue != null ? new CalRgb(calRgb, colorValue) : new CalRgb(calRgb); } else { if (colorSpace is PdfCieBasedCs.IccBased) { PdfCieBasedCs.IccBased iccBased = (PdfCieBasedCs.IccBased)colorSpace; c = colorValue != null ? new IccBased(iccBased, colorValue) : new IccBased(iccBased); } else { if (colorSpace is PdfCieBasedCs.Lab) { PdfCieBasedCs.Lab lab = (PdfCieBasedCs.Lab)colorSpace; c = colorValue != null ? new Lab(lab, colorValue) : new Lab(lab); } else { unknownColorSpace = true; } } } } } else { if (colorSpace is PdfSpecialCs) { if (colorSpace is PdfSpecialCs.Separation) { PdfSpecialCs.Separation separation = (PdfSpecialCs.Separation)colorSpace; c = colorValue != null ? new Separation(separation, colorValue[0]) : new Separation(separation); } else { if (colorSpace is PdfSpecialCs.DeviceN) { //NChannel goes here also PdfSpecialCs.DeviceN deviceN = (PdfSpecialCs.DeviceN)colorSpace; c = colorValue != null ? new DeviceN(deviceN, colorValue) : new DeviceN(deviceN); } else { if (colorSpace is PdfSpecialCs.Indexed) { c = colorValue != null ? new Indexed(colorSpace, (int)colorValue[0]) : new Indexed(colorSpace); } else { unknownColorSpace = true; } } } } else { if (colorSpace is PdfSpecialCs.Pattern) { c = new iText.Kernel.Colors.Color(colorSpace, colorValue); } else { // TODO review this. at least log a warning unknownColorSpace = true; } } } } if (unknownColorSpace) { throw new PdfException("Unknown color space."); } return(c); }
public Lab(PdfCieBasedCs.Lab cs) // TODO if zero is outside of the Range, default value should be the nearest to the zero valid value : this(cs, new float[cs.GetNumberOfComponents()]) { }
public Lab(PdfCieBasedCs.Lab cs, float[] value) : base(cs, value) { }
public Lab(PdfCieBasedCs.Lab cs) : this(cs, new float[cs.GetNumberOfComponents()]) { }