public static PdfFunction Type3(PdfWriter writer, float[] domain, float[] range, PdfFunction[] functions, float[] bounds, float[] encode) { var func = new PdfFunction(writer) { Dictionary = new PdfDictionary() }; func.Dictionary.Put(PdfName.Functiontype, new PdfNumber(3)); func.Dictionary.Put(PdfName.Domain, new PdfArray(domain)); if (range != null) { func.Dictionary.Put(PdfName.Range, new PdfArray(range)); } var array = new PdfArray(); for (var k = 0; k < functions.Length; ++k) { array.Add(functions[k].Reference); } func.Dictionary.Put(PdfName.Functions, array); func.Dictionary.Put(PdfName.Bounds, new PdfArray(bounds)); func.Dictionary.Put(PdfName.Encode, new PdfArray(encode)); return(func); }
public static PdfFunction Type0(PdfWriter writer, float[] domain, float[] range, int[] size, int bitsPerSample, int order, float[] encode, float[] decode, byte[] stream) { var func = new PdfFunction(writer) { Dictionary = new PdfStream(stream) }; ((PdfStream)func.Dictionary).FlateCompress(writer.CompressionLevel); func.Dictionary.Put(PdfName.Functiontype, new PdfNumber(0)); func.Dictionary.Put(PdfName.Domain, new PdfArray(domain)); func.Dictionary.Put(PdfName.Range, new PdfArray(range)); func.Dictionary.Put(PdfName.Size, new PdfArray(size)); func.Dictionary.Put(PdfName.Bitspersample, new PdfNumber(bitsPerSample)); if (order != 1) { func.Dictionary.Put(PdfName.Order, new PdfNumber(order)); } if (encode != null) { func.Dictionary.Put(PdfName.Encode, new PdfArray(encode)); } if (decode != null) { func.Dictionary.Put(PdfName.Decode, new PdfArray(decode)); } return(func); }
public static PdfFunction Type2(PdfWriter writer, float[] domain, float[] range, float[] c0, float[] c1, float n) { var func = new PdfFunction(writer) { Dictionary = new PdfDictionary() }; func.Dictionary.Put(PdfName.Functiontype, new PdfNumber(2)); func.Dictionary.Put(PdfName.Domain, new PdfArray(domain)); if (range != null) { func.Dictionary.Put(PdfName.Range, new PdfArray(range)); } if (c0 != null) { func.Dictionary.Put(PdfName.C0, new PdfArray(c0)); } if (c1 != null) { func.Dictionary.Put(PdfName.C1, new PdfArray(c1)); } func.Dictionary.Put(PdfName.N, new PdfNumber(n)); return(func); }
public Separation(String name, PdfColorSpace alternateSpace, PdfFunction tintTransform) : this(new PdfName(name), alternateSpace.GetPdfObject(), tintTransform.GetPdfObject()) { if (!tintTransform.CheckCompatibilityWithColorSpace(alternateSpace)) { throw new PdfException(PdfException.FunctionIsNotCompatibleWitColorSpace, this); } }
public DeviceN(IList <String> names, PdfColorSpace alternateSpace, PdfFunction tintTransform) : this(new PdfArray(names, true), alternateSpace.GetPdfObject(), tintTransform.GetPdfObject()) { if (tintTransform.GetInputSize() != GetNumberOfComponents() || tintTransform.GetOutputSize() != alternateSpace .GetNumberOfComponents()) { throw new PdfException(PdfException.FunctionIsNotCompatibleWitColorSpace, this); } }
public static PdfFunction Type4(PdfWriter writer, float[] domain, float[] range, string postscript) { byte[] b = new byte[postscript.Length]; for (int k = 0; k < b.Length; ++k) { b[k] = (byte)postscript[k]; } PdfFunction func = new PdfFunction(writer); func.Dictionary = new PdfStream(b); ((PdfStream)func.Dictionary).FlateCompress(writer.CompressionLevel); func.Dictionary.Put(PdfName.Functiontype, new PdfNumber(4)); func.Dictionary.Put(PdfName.Domain, new PdfArray(domain)); func.Dictionary.Put(PdfName.Range, new PdfArray(range)); return(func); }
private static void GetFunctionDetails(PdfDictionary dict) { var function = new PdfFunction(dict); int[] domain; int[] encode; switch (function.GetFunctionType()) { case 0: domain = GetItemsInt(dict.GetAsArray(PdfName.Domain)); GetItemsInt(dict.GetAsArray(PdfName.Size)); dict.GetAsInt(PdfName.BitsPerSample); dict.GetAsInt(PdfName.Order); encode = GetItemsInt(dict.GetAsArray(PdfName.Encode)); var decode = GetItemsInt(dict.GetAsArray(PdfName.Decode)); var range = GetItemsInt(dict.GetAsArray(PdfName.Range)); break; case 2: domain = GetItemsInt(dict.GetAsArray(PdfName.Domain)); var color1 = GetItemsFloat(dict.GetAsArray(PdfName.C0)); var color2 = GetItemsFloat(dict.GetAsArray(PdfName.C1)); var n = dict.GetAsInt(PdfName.N); break; case 3: domain = GetItemsInt(dict.GetAsArray(PdfName.Domain)); foreach (var sub in GetItemsDict(dict.GetAsArray(PdfName.Functions))) { GetFunctionDetails(sub); } var bounds = GetItemsFloat(dict.GetAsArray(PdfName.Bounds)); encode = GetItemsInt(dict.GetAsArray(PdfName.Encode)); break; case 4: domain = GetItemsInt(dict.GetAsArray(PdfName.Domain)); break; } }
public DeviceN(IList <String> names, PdfColorSpace alternateCs, PdfFunction tintTransform, float[] value) : this(new PdfSpecialCs.DeviceN(names, alternateCs, tintTransform), value) { }
public Separation(String name, PdfColorSpace alternateCs, PdfFunction tintTransform, float value) : this(new PdfSpecialCs.Separation(name, alternateCs, tintTransform), value) { }
public Radial(PdfColorSpace cs, PdfArray coords, PdfFunction function) : base(new PdfDictionary(), PdfShading.ShadingType.RADIAL, cs.GetPdfObject()) { SetCoords(coords); SetFunction(function); }
public FunctionBased(PdfObject colorSpace, PdfFunction function) : base(new PdfDictionary(), PdfShading.ShadingType.FUNCTION_BASED, colorSpace) { SetFunction(function); }
public FunctionBased(PdfColorSpace colorSpace, PdfFunction function) : this(colorSpace.GetPdfObject(), function) { }
public virtual void SetFunction(PdfFunction function) { GetPdfObject().Put(PdfName.Function, function.GetPdfObject()); SetModified(); }