当前位置: 首页>>代码示例>>C#>>正文


C# PdfArray.Add方法代码示例

本文整理汇总了C#中PdfArray.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PdfArray.Add方法的具体用法?C# PdfArray.Add怎么用?C# PdfArray.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PdfArray的用法示例。


在下文中一共展示了PdfArray.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PdfResources

 static PdfResources()
 {
     DefaultProcedureSets = new PdfArray();
     DefaultProcedureSets.Add(PdfName.Names.PDF);
     DefaultProcedureSets.Add(PdfName.Names.Text);
     DefaultProcedureSets.Add(PdfName.Names.ImageB);
     DefaultProcedureSets.Add(PdfName.Names.ImageC);
     DefaultProcedureSets.Add(PdfName.Names.ImageI);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:PdfResources.cs

示例2: PdfGoToRemote

 static PdfGoToRemote()
 {
     DefaultDestination = new PdfArray();
     DefaultDestination.Add(new PdfNumeric(0));
     DefaultDestination.Add(PdfName.Names.XYZ);
     DefaultDestination.Add(PdfNull.Null);
     DefaultDestination.Add(PdfNull.Null);
     DefaultDestination.Add(PdfNull.Null);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:9,代码来源:PdfGoToRemote.cs

示例3: Write

 protected internal override void Write(PdfWriter writer)
 {
     PdfArray dest = new PdfArray();
     dest.Add(pageReference);
     dest.Add(PdfName.Names.XYZ);
     dest.Add(new PdfNumeric(xPosition));
     dest.Add(new PdfNumeric(yPosition));
     dest.Add(PdfNull.Null);
     this[PdfName.Names.D] = dest;
     base.Write(writer);
 }
开发者ID:nholik,项目名称:Fo.Net,代码行数:11,代码来源:PdfGoTo.cs

示例4: CleverPdfArrayClone

        private PdfObject CleverPdfArrayClone(PdfArray array) {
            PdfArray newArray = new PdfArray();
            for (int i = 0; i < array.Size; i++) {
                PdfObject obj = array[i];
                if (obj is PdfDictionary)
                    newArray.Add(CleverPdfDictionaryClone((PdfDictionary) obj));
                else
                    newArray.Add(obj);
            }

            return newArray;
        }
开发者ID:Niladri24dutta,项目名称:itextsharp,代码行数:12,代码来源:PdfAChecker.cs

示例5: PdfPage

        public PdfPage(
            PdfResources resources,
            PdfContentStream contents,
            int pagewidth,
            int pageheight,
            PdfObjectId objectId)
            : base(objectId)
        {
            this[PdfName.Names.Type] = PdfName.Names.Page;
            this[PdfName.Names.Resources] = resources.GetReference();
            this[PdfName.Names.Contents] = contents.GetReference();

            PdfArray mediaBox = new PdfArray();
            mediaBox.Add(new PdfNumeric(0));
            mediaBox.Add(new PdfNumeric(0));
            mediaBox.Add(new PdfNumeric(pagewidth));
            mediaBox.Add(new PdfNumeric(pageheight));
            this[PdfName.Names.MediaBox] = mediaBox;
        }
开发者ID:nholik,项目名称:Fo.Net,代码行数:19,代码来源:PdfPage.cs

示例6: IndexedModel

 private Image IndexedModel(byte[] bdata, int bpc, int paletteEntries) {
     Image img = new ImgRaw(width, height, 1, bpc, bdata);
     PdfArray colorspace = new PdfArray();
     colorspace.Add(PdfName.INDEXED);
     colorspace.Add(PdfName.DEVICERGB);
     byte[] np = GetPalette(paletteEntries);
     int len = np.Length;
     colorspace.Add(new PdfNumber(len / 3 - 1));
     colorspace.Add(new PdfString(np));
     PdfDictionary ad = new PdfDictionary();
     ad.Put(PdfName.COLORSPACE, colorspace);
     img.Additional = ad;
     return img;
 }
开发者ID:red-gate,项目名称:iTextSharp-4.1.6,代码行数:14,代码来源:BmpImage.cs

示例7: OutputDss

 private void OutputDss(PdfDictionary dss, PdfDictionary vrim, PdfArray ocsps, PdfArray crls, PdfArray certs) {
     writer.AddDeveloperExtension(PdfDeveloperExtension.ESIC_1_7_EXTENSIONLEVEL5);
     PdfDictionary catalog = reader.Catalog;
     stp.MarkUsed(catalog);
     foreach (PdfName vkey in validated.Keys) {
         PdfArray ocsp = new PdfArray();
         PdfArray crl = new PdfArray();
         PdfArray cert = new PdfArray();
         PdfDictionary vri = new PdfDictionary();
         foreach (byte[] b in validated[vkey].crls) {
             PdfStream ps = new PdfStream(b);
             ps.FlateCompress();
             PdfIndirectReference iref = writer.AddToBody(ps, false).IndirectReference;
             crl.Add(iref);
             crls.Add(iref);
         }
         foreach (byte[] b in validated[vkey].ocsps) {
             PdfStream ps = new PdfStream(b);
             ps.FlateCompress();
             PdfIndirectReference iref = writer.AddToBody(ps, false).IndirectReference;
             ocsp.Add(iref);
             ocsps.Add(iref);
         }
         foreach (byte[] b in validated[vkey].certs) {
             PdfStream ps = new PdfStream(b);
             ps.FlateCompress();
             PdfIndirectReference iref = writer.AddToBody(ps, false).IndirectReference;
             cert.Add(iref);
             certs.Add(iref);
         }
         if (ocsp.Size > 0)
             vri.Put(PdfName.OCSP, writer.AddToBody(ocsp, false).IndirectReference);
         if (crl.Size > 0)
             vri.Put(PdfName.CRL, writer.AddToBody(crl, false).IndirectReference);
         if (cert.Size > 0)
             vri.Put(PdfName.CERT, writer.AddToBody(cert, false).IndirectReference);
         vrim.Put(vkey, writer.AddToBody(vri, false).IndirectReference);
     }
     dss.Put(PdfName.VRI, writer.AddToBody(vrim, false).IndirectReference);
     if (ocsps.Size > 0)
         dss.Put(PdfName.OCSPS, writer.AddToBody(ocsps, false).IndirectReference);
     if (crls.Size > 0)
         dss.Put(PdfName.CRLS, writer.AddToBody(crls, false).IndirectReference);
     if (certs.Size > 0)
         dss.Put(PdfName.CERTS, writer.AddToBody(certs, false).IndirectReference);
     catalog.Put(PdfName.DSS, writer.AddToBody(dss, false).IndirectReference);
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:47,代码来源:LtvVerification.cs

示例8: ParsePdfObject

   /**
     <summary>Parses the current PDF object [PDF:1.6:3.2].</summary>
   */
   public virtual PdfDataObject ParsePdfObject(
 )
   {
       switch(TokenType)
         {
       case TokenTypeEnum.Integer:
         return PdfInteger.Get((int)Token);
       case TokenTypeEnum.Name:
         return new PdfName((string)Token,true);
       case TokenTypeEnum.DictionaryBegin:
       {
         PdfDictionary dictionary = new PdfDictionary();
         dictionary.Updateable = false;
         while(true)
         {
       // Key.
       MoveNext(); if(TokenType == TokenTypeEnum.DictionaryEnd) break;
       PdfName key = (PdfName)ParsePdfObject();
       // Value.
       MoveNext();
       PdfDirectObject value = (PdfDirectObject)ParsePdfObject();
       // Add the current entry to the dictionary!
       dictionary[key] = value;
         }
         dictionary.Updateable = true;
         return dictionary;
       }
       case TokenTypeEnum.ArrayBegin:
       {
         PdfArray array = new PdfArray();
         array.Updateable = false;
         while(true)
         {
       // Value.
       MoveNext(); if(TokenType == TokenTypeEnum.ArrayEnd) break;
       // Add the current item to the array!
       array.Add((PdfDirectObject)ParsePdfObject());
         }
         array.Updateable = true;
         return array;
       }
       case TokenTypeEnum.Literal:
         if(Token is DateTime)
       return PdfDate.Get((DateTime)Token);
         else
       return new PdfTextString(
         Encoding.Pdf.Encode((string)Token)
         );
       case TokenTypeEnum.Hex:
         return new PdfTextString(
       (string)Token,
       PdfString.SerializationModeEnum.Hex
       );
       case TokenTypeEnum.Real:
         return PdfReal.Get((double)Token);
       case TokenTypeEnum.Boolean:
         return PdfBoolean.Get((bool)Token);
       case TokenTypeEnum.Null:
         return null;
       default:
         throw new Exception("Unknown type: " + TokenType);
         }
   }
开发者ID:josuecorrea,项目名称:DanfeSharp,代码行数:66,代码来源:BaseParser.cs

示例9: SetMatrix

 public void SetMatrix(float a, float b, float c, float d, float e, float f) {
     matrix = new PdfArray();
     matrix.Add(new PdfNumber(a));
     matrix.Add(new PdfNumber(b));
     matrix.Add(new PdfNumber(c));
     matrix.Add(new PdfNumber(d));
     matrix.Add(new PdfNumber(e));
     matrix.Add(new PdfNumber(f));
 }
开发者ID:,项目名称:,代码行数:9,代码来源:

示例10: GetAlternateValue

 /**
  * Transforms value abbreviations into their corresponding real value 
  * @param key the key that the value is for
  * @param value the value that might be an abbreviation
  * @return if value is an allowed abbreviation for the key, the expanded value for that abbreviation.  Otherwise, value is returned without modification 
  */
 private static PdfObject GetAlternateValue(PdfName key, PdfObject value){
     if (key == PdfName.FILTER){
         if (value is PdfName){
             PdfName altValue;
             inlineImageFilterAbbreviationMap.TryGetValue((PdfName)value, out altValue);
             if (altValue != null)
                 return altValue;
         } else if (value is PdfArray){
             PdfArray array = ((PdfArray)value);
             PdfArray altArray = new PdfArray();
             int count = array.Size;
             for (int i = 0; i < count; i++){
                 altArray.Add(GetAlternateValue(key, array[i]));
             }
             return altArray;
         }
     } else if (key == PdfName.COLORSPACE){
         if (value is PdfName){
             PdfName altValue;
             inlineImageColorSpaceAbbreviationMap.TryGetValue((PdfName)value, out altValue);
             if (altValue != null)
                 return altValue;
         }
     }
     
     return value;
 }
开发者ID:,项目名称:,代码行数:33,代码来源:

示例11: Flush

        public void Flush(
            )
        {
            // Ensuring that there's room for the new content chunks inside the page's content stream...
              /*
            NOTE: This specialized stamper is optimized for content insertion without modifying
            existing content representations, leveraging the peculiar feature of page structures
            to express their content streams as arrays of data streams.
              */
              PdfArray streams;
              {
            PdfDirectObject contentsObject = page.BaseDataObject[PdfName.Contents];
            PdfDataObject contentsDataObject = PdfObject.Resolve(contentsObject);
            // Single data stream?
            if(contentsDataObject is PdfStream)
            {
              /*
            NOTE: Content stream MUST be expressed as an array of data streams in order to host
            background- and foreground-stamped contents.
              */
              streams = new PdfArray();
              streams.Add(contentsObject);
              page.BaseDataObject[PdfName.Contents] = streams;
            }
            else
            {streams = (PdfArray)contentsDataObject;}
              }

              // Background.
              // Serialize the content!
              background.Flush();
              // Insert the serialized content into the page's content stream!
              streams.Insert(0, background.Scanner.Contents.BaseObject);

              // Foreground.
              // Serialize the content!
              foreground.Flush();
              // Append the serialized content into the page's content stream!
              streams.Add(foreground.Scanner.Contents.BaseObject);
        }
开发者ID:n9,项目名称:pdfclown,代码行数:40,代码来源:PageStamper.cs

示例12: GetTiffImageColor


//.........这里部分代码省略.........

                int posFilePointer = s.FilePointer;
                posFilePointer += jpegOffset;
                s.Seek(posFilePointer);
                s.ReadFully(jpeg);
                img = new Jpeg(jpeg);
            }
            else if (compression == TIFFConstants.COMPRESSION_JPEG) {
                if (size.Length > 1)
                    throw new IOException("Compression JPEG is only supported with a single strip. This image has " + size.Length + " strips.");
                byte[] jpeg = new byte[(int)size[0]];
                s.Seek(offset[0]);
                s.ReadFully(jpeg);
                img = new Jpeg(jpeg);
            }
            else {
                for (int k = 0; k < offset.Length; ++k) {
                    byte[] im = new byte[(int)size[k]];
                    s.Seek(offset[k]);
                    s.ReadFully(im);
                    int height = Math.Min(rowsStrip, rowsLeft);
                    byte[] outBuf = null;
                    if (compression != TIFFConstants.COMPRESSION_NONE)
                        outBuf = new byte[(w * bitsPerSample * samplePerPixel + 7) / 8 * height];
                    if (reverse)
                        TIFFFaxDecoder.ReverseBits(im);
                    switch (compression) {
                        case TIFFConstants.COMPRESSION_DEFLATE:
                        case TIFFConstants.COMPRESSION_ADOBE_DEFLATE:
                            Inflate(im, outBuf);
                            break;
                        case TIFFConstants.COMPRESSION_NONE:
                            outBuf = im;
                            break;
                        case TIFFConstants.COMPRESSION_PACKBITS:
                            DecodePackbits(im,  outBuf);
                            break;
                        case TIFFConstants.COMPRESSION_LZW:
                            lzwDecoder.Decode(im, outBuf, height);
                            break;
                    }
                    if (bitsPerSample == 1 && samplePerPixel == 1) {
                        g4.Fax4Encode(outBuf, height);
                    }
                    else {
                        zip.Write(outBuf, 0, outBuf.Length);
                    }
                    rowsLeft -= rowsStrip;
                }
                if (bitsPerSample == 1 && samplePerPixel == 1) {
                    img = Image.GetInstance(w, h, false, Image.CCITTG4,
                        photometric == TIFFConstants.PHOTOMETRIC_MINISBLACK ? Image.CCITT_BLACKIS1 : 0, g4.Close());
                }
                else {
                    zip.Close();
                    img = Image.GetInstance(w, h, samplePerPixel, bitsPerSample, stream.ToArray());
                    img.Deflated = true;
                }
            }
            img.SetDpi(dpiX, dpiY);
            if (compression != TIFFConstants.COMPRESSION_OJPEG && compression != TIFFConstants.COMPRESSION_JPEG) {
                if (dir.IsTagPresent(TIFFConstants.TIFFTAG_ICCPROFILE)) {
                    try {
                        TIFFField fd = dir.GetField(TIFFConstants.TIFFTAG_ICCPROFILE);
                        ICC_Profile icc_prof = ICC_Profile.GetInstance(fd.GetAsBytes());
                        if (samplePerPixel == icc_prof.NumComponents)
                            img.TagICC = icc_prof;
                    }
                    catch {
                        //empty
                    }
                }
                if (dir.IsTagPresent(TIFFConstants.TIFFTAG_COLORMAP)) {
                    TIFFField fd = dir.GetField(TIFFConstants.TIFFTAG_COLORMAP);
                    char[] rgb = fd.GetAsChars();
                    byte[] palette = new byte[rgb.Length];
                    int gColor = rgb.Length / 3;
                    int bColor = gColor * 2;
                    for (int k = 0; k < gColor; ++k) {
                        palette[k * 3] = (byte)(rgb[k] >> 8);
                        palette[k * 3 + 1] = (byte)(rgb[k + gColor] >> 8);
                        palette[k * 3 + 2] = (byte)(rgb[k + bColor] >> 8);
                    }
                    PdfArray indexed = new PdfArray();
                    indexed.Add(PdfName.INDEXED);
                    indexed.Add(PdfName.DEVICERGB);
                    indexed.Add(new PdfNumber(gColor - 1));
                    indexed.Add(new PdfString(palette));
                    PdfDictionary additional = new PdfDictionary();
                    additional.Put(PdfName.COLORSPACE, indexed);
                    img.Additional = additional;
                }
                img.OriginalType = Image.ORIGINAL_TIFF;
            }
            if (photometric == TIFFConstants.PHOTOMETRIC_MINISWHITE)
                img.Inverted = true;
            if (rotation != 0)
                img.InitialRotation = rotation;
            return img;
        }
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:101,代码来源:TiffImage.cs

示例13: Load_CreateEncoding


//.........这里部分代码省略.........
              + "/CMapType 2 def\n"
              + "2 begincodespacerange\n"
              + "<20> <20>\n"
              + "<0000> <19FF>\n"
              + "endcodespacerange\n"
              + glyphIndexes.Count + " beginbfchar\n"
            );
              // CIDToGIDMap [PDF:1.6:5.6.3].
              bytes::Buffer gIdBuffer = new bytes::Buffer();
              gIdBuffer.Append((byte)0);
              gIdBuffer.Append((byte)0);
              int code = 0;
              codes = new BiDictionary<ByteArray,int>(glyphIndexes.Count);
              PdfArray widthsObject = new PdfArray(glyphWidths.Count);
              foreach(KeyValuePair<int,int> glyphIndexEntry in glyphIndexes)
              {
            // Character code (unicode to codepoint) entry.
            code++;
            byte[] charCode = (glyphIndexEntry.Key == 32
              ? new byte[]{32}
              : new byte[]
            {
              (byte)((code >> 8) & 0xFF),
              (byte)(code & 0xFF)
            });
            codes[new ByteArray(charCode)] = glyphIndexEntry.Key;

            // CMap entry.
            cmapBuffer.Append("<");
            toUnicodeBuffer.Append("<");
            for(int charCodeBytesIndex = 0,
            charCodeBytesLength = charCode.Length;
              charCodeBytesIndex < charCodeBytesLength;
              charCodeBytesIndex++
              )
            {
              string hex = ((int)charCode[charCodeBytesIndex]).ToString("X2");
              cmapBuffer.Append(hex);
              toUnicodeBuffer.Append(hex);
            }
            cmapBuffer.Append("> " + code + "\n");
            toUnicodeBuffer.Append("> <" + glyphIndexEntry.Key.ToString("X4") + ">\n");

            // CID-to-GID entry.
            int glyphIndex = glyphIndexEntry.Value;
            gIdBuffer.Append((byte)((glyphIndex >> 8) & 0xFF));
            gIdBuffer.Append((byte)(glyphIndex & 0xFF));

            // Width.
            int width;
            if(!glyphWidths.TryGetValue(glyphIndex, out width))
            {width = 0;}
            else if(width > 1000)
            {width = 1000;}
            widthsObject.Add(PdfInteger.Get(width));
              }
              cmapBuffer.Append(
            "endcidchar\n"
              + "endcmap\n"
              + "CMapName currentdict /CMap defineresource pop\n"
              + "end\n"
              + "end\n"
              + "%%EndResource\n"
              + "%%EOF"
            );
              PdfStream cmapStream = new PdfStream(cmapBuffer);
              PdfDictionary cmapHead = cmapStream.Header;
              cmapHead[PdfName.Type] = PdfName.CMap;
              cmapHead[PdfName.CMapName] = new PdfName("Adobe-Identity-UCS");
              cmapHead[PdfName.CIDSystemInfo] = new PdfDictionary(
            new PdfName[]
            {
              PdfName.Registry,
              PdfName.Ordering,
              PdfName.Supplement
            },
            new PdfDirectObject[]
            {
              new PdfTextString("Adobe"),
              new PdfTextString("Identity"),
              PdfInteger.Get(0)
            }
            ); // Generic predefined CMap (Identity-H/V (Adobe-Identity-0)) [PDF:1.6:5.6.4].
              font[PdfName.Encoding] = File.Register(cmapStream);

              PdfStream gIdStream = new PdfStream(gIdBuffer);
              cidFont[PdfName.CIDToGIDMap] = File.Register(gIdStream);

              cidFont[PdfName.W] = new PdfArray(new PdfDirectObject[]{PdfInteger.Get(1),widthsObject});

              toUnicodeBuffer.Append(
            "endbfchar\n"
              + "endcmap\n"
              + "CMapName currentdict /CMap defineresource pop\n"
              + "end\n"
              + "end\n"
            );
              PdfStream toUnicodeStream = new PdfStream(toUnicodeBuffer);
              font[PdfName.ToUnicode] = File.Register(toUnicodeStream);
        }
开发者ID:n9,项目名称:pdfclown,代码行数:101,代码来源:CompositeFont.cs

示例14: ReadPng

        void ReadPng()
        {
            for (int i = 0; i < PNGID.Length; i++) {
                if (PNGID[i] != isp.ReadByte())	{
                    throw new IOException("File is not a valid PNG.");
                }
            }
            byte[] buffer = new byte[TRANSFERSIZE];
            while (true) {
                int len = GetInt(isp);
                String marker = GetString(isp);
                if (len < 0 || !CheckMarker(marker))
                    throw new IOException("Corrupted PNG file.");
                if (IDAT.Equals(marker)) {
                    int size;
                    while (len != 0) {
                        size = isp.Read(buffer, 0, Math.Min(len, TRANSFERSIZE));
                        if (size <= 0)
                            return;
                        idat.Write(buffer, 0, size);
                        len -= size;
                    }
                }
                else if (tRNS.Equals(marker)) {
                    switch (colorType) {
                        case 0:
                            if (len >= 2) {
                                len -= 2;
                                int gray = GetWord(isp);
                                if (bitDepth == 16)
                                    transRedGray = gray;
                                else
                                    additional.Put(PdfName.MASK, new PdfLiteral("["+gray+" "+gray+"]"));
                            }
                            break;
                        case 2:
                            if (len >= 6) {
                                len -= 6;
                                int red = GetWord(isp);
                                int green = GetWord(isp);
                                int blue = GetWord(isp);
                                if (bitDepth == 16) {
                                    transRedGray = red;
                                    transGreen = green;
                                    transBlue = blue;
                                }
                                else
                                    additional.Put(PdfName.MASK, new PdfLiteral("["+red+" "+red+" "+green+" "+green+" "+blue+" "+blue+"]"));
                            }
                            break;
                        case 3:
                            if (len > 0) {
                                trans = new byte[len];
                                for (int k = 0; k < len; ++k)
                                    trans[k] = (byte)isp.ReadByte();
                                len = 0;
                            }
                            break;
                    }
                    Utilities.Skip(isp, len);
                }
                else if (IHDR.Equals(marker)) {
                    width = GetInt(isp);
                    height = GetInt(isp);

                    bitDepth = isp.ReadByte();
                    colorType = isp.ReadByte();
                    compressionMethod = isp.ReadByte();
                    filterMethod = isp.ReadByte();
                    interlaceMethod = isp.ReadByte();
                }
                else if (PLTE.Equals(marker)) {
                    if (colorType == 3) {
                        PdfArray colorspace = new PdfArray();
                        colorspace.Add(PdfName.INDEXED);
                        colorspace.Add(GetColorspace());
                        colorspace.Add(new PdfNumber(len / 3 - 1));
                        ByteBuffer colortable = new ByteBuffer();
                        while ((len--) > 0) {
                            colortable.Append_i(isp.ReadByte());
                        }
                        colorspace.Add(new PdfString(colorTable = colortable.ToByteArray()));
                        additional.Put(PdfName.COLORSPACE, colorspace);
                    }
                    else {
                        Utilities.Skip(isp, len);
                    }
                }
                else if (pHYs.Equals(marker)) {
                    int dx = GetInt(isp);
                    int dy = GetInt(isp);
                    int unit = isp.ReadByte();
                    if (unit == 1) {
                        dpiX = (int)((float)dx * 0.0254f + 0.5f);
                        dpiY = (int)((float)dy * 0.0254f + 0.5f);
                    }
                    else {
                        if (dy != 0)
                            XYRatio = (float)dx / (float)dy;
                    }
//.........这里部分代码省略.........
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:101,代码来源:PngImage.cs

示例15: GetColorspace

 PdfObject GetColorspace()
 {
     if (icc_profile != null) {
         if ((colorType & 2) == 0)
             return PdfName.DEVICEGRAY;
         else
             return PdfName.DEVICERGB;
     }
     if (gamma == 1f && !hasCHRM) {
         if ((colorType & 2) == 0)
             return PdfName.DEVICEGRAY;
         else
             return PdfName.DEVICERGB;
     }
     else {
         PdfArray array = new PdfArray();
         PdfDictionary dic = new PdfDictionary();
         if ((colorType & 2) == 0) {
             if (gamma == 1f)
                 return PdfName.DEVICEGRAY;
             array.Add(PdfName.CALGRAY);
             dic.Put(PdfName.GAMMA, new PdfNumber(gamma));
             dic.Put(PdfName.WHITEPOINT, new PdfLiteral("[1 1 1]"));
             array.Add(dic);
         }
         else {
             PdfObject wp = new PdfLiteral("[1 1 1]");
             array.Add(PdfName.CALRGB);
             if (gamma != 1f) {
                 PdfArray gm = new PdfArray();
                 PdfNumber n = new PdfNumber(gamma);
                 gm.Add(n);
                 gm.Add(n);
                 gm.Add(n);
                 dic.Put(PdfName.GAMMA, gm);
             }
             if (hasCHRM) {
                 float z = yW*((xG-xB)*yR-(xR-xB)*yG+(xR-xG)*yB);
                 float YA = yR*((xG-xB)*yW-(xW-xB)*yG+(xW-xG)*yB)/z;
                 float XA = YA*xR/yR;
                 float ZA = YA*((1-xR)/yR-1);
                 float YB = -yG*((xR-xB)*yW-(xW-xB)*yR+(xW-xR)*yB)/z;
                 float XB = YB*xG/yG;
                 float ZB = YB*((1-xG)/yG-1);
                 float YC = yB*((xR-xG)*yW-(xW-xG)*yW+(xW-xR)*yG)/z;
                 float XC = YC*xB/yB;
                 float ZC = YC*((1-xB)/yB-1);
                 float XW = XA+XB+XC;
                 float YW = 1;//YA+YB+YC;
                 float ZW = ZA+ZB+ZC;
                 PdfArray wpa = new PdfArray();
                 wpa.Add(new PdfNumber(XW));
                 wpa.Add(new PdfNumber(YW));
                 wpa.Add(new PdfNumber(ZW));
                 wp = wpa;
                 PdfArray matrix = new PdfArray();
                 matrix.Add(new PdfNumber(XA));
                 matrix.Add(new PdfNumber(YA));
                 matrix.Add(new PdfNumber(ZA));
                 matrix.Add(new PdfNumber(XB));
                 matrix.Add(new PdfNumber(YB));
                 matrix.Add(new PdfNumber(ZB));
                 matrix.Add(new PdfNumber(XC));
                 matrix.Add(new PdfNumber(YC));
                 matrix.Add(new PdfNumber(ZC));
                 dic.Put(PdfName.MATRIX, matrix);
             }
             dic.Put(PdfName.WHITEPOINT, wp);
             array.Add(dic);
         }
         return array;
     }
 }
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:73,代码来源:PngImage.cs


注:本文中的PdfArray.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。