public override double[] this[double[] args] { get { int num1; int num2; int num4; if (args.Length != this.Domain.Count) { throw new ArgumentException("Incorrect number of arguments", "args"); } double[] numArray1 = new double[args.Length]; for (num1 = 0; (num1 < numArray1.Length); num1 += 1) { numArray1[num1] = Math.Min(Math.Max(args[num1], this.Domain[num1].Min), this.Domain[num1].Max); numArray1[num1] = Function.InterpolateLin1d(numArray1[num1], this.Domain[num1].Min, this.Domain[num1].Max, this.Encode[num1].Min, this.Encode[num1].Max); } Stream stream1 = ((PDFStream)this.mDirect).Decode(); byte[] numArray2 = new byte[((IntPtr)stream1.Length)]; stream1.Read(numArray2, 0, numArray2.Length); BitArrayAccessor accessor1 = new BitArrayAccessor(numArray2, this.BitsPerSample, false); int[] numArray3 = new int[this.Size.Count]; for (num2 = 0; (num2 < numArray3.Length); num2 += 1) { numArray3[num2] = ((int)this.Size[num2]); } double[] numArray4 = Type0FunctionCalculator.Calculate(this.Order, accessor1, numArray3, this.Range.Count, numArray1); double num3 = (Math.Pow(2f, ((double)this.BitsPerSample)) - 1f); for (num4 = 0; (num4 < numArray4.Length); num4 += 1) { numArray4[num4] = Function.InterpolateLin1d(numArray4[num4], 0f, num3, this.Decode[num4].Min, this.Decode[num4].Max); numArray4[num4] = Math.Min(Math.Max(numArray4[num4], this.Range[num4].Min), this.Range[num4].Max); } return(numArray4); } }
private void ReadXRefStream(long offset) { int num3; int num4; int num5; long num6; int num7; XRefEntry entry1; int num8; PDFObject obj1; PDFStream stream1 = (this.ReadDirectFromStream(this.mParser, offset, -1, -1) as PDFStream); if (stream1 == null) { throw new PDFException("Invalid XRef-Stream"); } PDFDict dict1 = stream1.Dict; PDFName name1 = (dict1["Type"] as PDFName); if (name1 == null) { throw new PDFException("Invalid XRef-Stream"); } int[] numArray1 = new int[3]; PDFArray array1 = (dict1["W"] as PDFArray); if (array1 == null) { throw new PDFException("Invalid or missing W entry in XRef stream"); } if (array1.Count != 3) { throw new PDFException("Invalid W entry in XRef stream (wrong number of elements"); } int num1 = 0; foreach (PDFInteger integer1 in array1) { int num9 = num1; num1 = (num9 + 1); numArray1[num1] = integer1.Int32Value; } PDFInteger integer2 = (dict1["Size"] as PDFInteger); if (integer2 == null) { throw new PDFException("Invalid or missing size entry"); } PDFArray array2 = (dict1["Index"] as PDFArray); if (array2 != null) { goto Label_0121; } throw new PDFException("Invalid or missing index entry"); Label_0114: this.mXRef.Add(null); Label_0121: if (((long)this.mXRef.Count) < integer2.Value) { goto Label_0114; } Stream stream2 = stream1.Decode(); byte[] numArray2 = new byte[((numArray1[0] + numArray1[1]) + numArray1[2])]; BitArrayAccessor accessor1 = new BitArrayAccessor(numArray2, 8, false); if (numArray1[1] < 0) { throw new PDFException("Invalid w2 value"); } int num2 = 0; try { while ((num2 < array2.Count)) { num3 = ((PDFInteger)array2[num2]).Int32Value; num4 = (num3 + ((PDFInteger)array2[(num2 + 1)]).Int32Value); num1 = num3; while ((num1 < num4)) { stream2.Read(numArray2, 0, numArray2.Length); if (this.mXRef[num1] != null) { goto Label_02A2; } num5 = ((numArray1[0] == 0) ? 1 : ((int)accessor1.GetBits(((long)0), (numArray1[0] * 8), 1, false, false)[0])); num6 = accessor1.GetBits(((long)(numArray1[0] * 8)), (numArray1[1] * 8), 1, false, false)[0]; if (numArray1[2] == 0) { if (num5 == 1) { num7 = 0; goto Label_023C; } throw new PDFException("Not default value for w3 for this object type"); } num7 = ((int)accessor1.GetBits(((long)((numArray1[0] + numArray1[1]) * 8)), (numArray1[2] * 8), 1, false, false)[0]); Label_023C: entry1 = new XRefEntry(); entry1.type = num5; num8 = num5; switch (num8) { case 0: case 1: { entry1.generation = num7; entry1.offset = num6; goto Label_0293; } case 2: { goto Label_0279; } } goto Label_0293; Label_0279: entry1.generation = 0; entry1.offset = num6; entry1.index = num7; Label_0293: this.mXRef[num1] = entry1; Label_02A2: num1 += 1; } num2 += 2; } } catch (InvalidCastException) { throw new PDFException("Invalid index entry"); } PDFInteger integer3 = (dict1["Prev"] as PDFInteger); if (integer3 != null) { this.ReadXRefStream(integer3.Value); } this.mXRefValid = true; this.mTrailer = new CorePDFDict(); if ((dict1["Root"] != null) && (this.mTrailer["Root"] == null)) { obj1 = dict1["Root"]; this.mTrailer["Root"] = obj1; this.mRoot = ((PDFDict)obj1); } if ((dict1["Info"] is PDFDict) && (this.mTrailer["Info"] == null)) { obj1 = dict1["Info"]; this.mTrailer["Info"] = obj1; this.mInfo = ((PDFDict)obj1); } }
public static XObjectImage Create(Document doc, Bitmap img, params string[] encoding) { int num3; int num4; int num5; Color color1; int num6; PDFArray array1; int num7; int num8; PDFStream stream1 = Library.CreateStream(); PDFDict dict1 = stream1.Dict; dict1["Width"] = PDF.O(img.Width); dict1["Height"] = PDF.O(img.Height); dict1["Subtype"] = PDF.N("Image"); dict1["Type"] = PDF.N("XObject"); byte[] numArray1 = null; BitArrayAccessor accessor1 = null; int num1 = 0; int num2 = 0; if (doc == null) { doc = Library.Resources.Doc; } XObjectImage image1 = ((XObjectImage)doc.Resources[doc.Indirects.New(stream1), typeof(XObjectImage)]); image1.ColorSpace = ColorSpaceDeviceRGB.Create(); numArray1 = new byte[((3 * img.Width) * img.Height)]; num1 = 8; num2 = (3 * img.Width); dict1["BitsPerComponent"] = PDF.O(8); for (num3 = 0; (num3 < img.Height); num3 += 1) { num4 = 0; accessor1 = new BitArrayAccessor(numArray1, ((num3 * num2) * 8), num1, false); for (num5 = 0; (num5 < img.Width); num5 += 1) { color1 = img.GetPixel(num5, num3); num6 = 0; while ((num6 < 3)) { num8 = num6; switch (num8) { case 0: { int num9 = num4; num4 = (num9 + 1); accessor1[num4] = ((long)((ulong)color1.R)); goto Label_0180; } case 1: { int num10 = num4; num4 = (num10 + 1); accessor1[num4] = ((long)((ulong)color1.G)); goto Label_0180; } case 2: { goto Label_016B; } } goto Label_0180; Label_016B: int num11 = num4; num4 = (num11 + 1); accessor1[num4] = ((long)((ulong)color1.B)); Label_0180: num6 += 1; } } } MemoryStream stream2 = new MemoryStream(numArray1); if (encoding.Length > 0) { array1 = Library.CreateArray(encoding.Length); stream1.Dict["Filter"] = array1; for (num7 = 0; (num7 < encoding.Length); num7 += 1) { array1[num7] = PDF.N(encoding[num7]); } } stream1.Encode(stream2); return(image1); }