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


C# PdfDictionary.Put方法代码示例

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


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

示例1: 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

示例2: SignDetached

        /**
         * Signs the document using the detached mode, CMS or CAdES equivalent.
         * @param sap the PdfSignatureAppearance
         * @param externalSignature the interface providing the actual signing
         * @param chain the certificate chain
         * @param crlList the CRL list
         * @param ocspClient the OCSP client
         * @param tsaClient the Timestamp client
         * @param provider the provider or null
         * @param estimatedSize the reserved size for the signature. It will be estimated if 0
         * @param cades true to sign CAdES equivalent PAdES-BES, false to sign CMS
         * @throws DocumentException 
         * @throws IOException 
         * @throws GeneralSecurityException 
         * @throws NoSuchAlgorithmException 
         * @throws Exception 
         */
        public static void SignDetached(PdfSignatureAppearance sap, IExternalSignature externalSignature, ICollection<X509Certificate> chain, ICollection<ICrlClient> crlList, IOcspClient ocspClient,
                ITSAClient tsaClient, int estimatedSize, CryptoStandard sigtype) {
            List<X509Certificate> certa = new List<X509Certificate>(chain);
            ICollection<byte[]> crlBytes = null;
            int i = 0;
            while (crlBytes == null && i < certa.Count)
        	    crlBytes = ProcessCrl(certa[i++], crlList);
            if (estimatedSize == 0) {
                estimatedSize = 8192;
                if (crlBytes != null) {
                    foreach (byte[] element in crlBytes) {
                        estimatedSize += element.Length + 10;
                    }
                }
                if (ocspClient != null)
                    estimatedSize += 4192;
                if (tsaClient != null)
                    estimatedSize += 4192;
            }
            sap.Certificate = certa[0];
            if(sigtype == CryptoStandard.CADES)
                sap.AddDeveloperExtension(PdfDeveloperExtension.ESIC_1_7_EXTENSIONLEVEL2);
            PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, sigtype == CryptoStandard.CADES ? PdfName.ETSI_CADES_DETACHED : PdfName.ADBE_PKCS7_DETACHED);
            dic.Reason = sap.Reason;
            dic.Location = sap.Location;
            dic.SignatureCreator = sap.SignatureCreator;
            dic.Contact = sap.Contact;
            dic.Date = new PdfDate(sap.SignDate); // time-stamp will over-rule this
            sap.CryptoDictionary = dic;

            Dictionary<PdfName, int> exc = new Dictionary<PdfName, int>();
            exc[PdfName.CONTENTS] = estimatedSize * 2 + 2;
            sap.PreClose(exc);

            String hashAlgorithm = externalSignature.GetHashAlgorithm();
            PdfPKCS7 sgn = new PdfPKCS7(null, chain, hashAlgorithm, false);
            IDigest messageDigest = DigestUtilities.GetDigest(hashAlgorithm);
            Stream data = sap.GetRangeStream();
            byte[] hash = DigestAlgorithms.Digest(data, hashAlgorithm);
            DateTime cal = DateTime.Now;
            byte[] ocsp = null;
            if (chain.Count >= 2 && ocspClient != null) {
                ocsp = ocspClient.GetEncoded(certa[0], certa[1], null);
            }
            byte[] sh = sgn.getAuthenticatedAttributeBytes(hash, cal, ocsp, crlBytes, sigtype);
            byte[] extSignature = externalSignature.Sign(sh);
            sgn.SetExternalDigest(extSignature, null, externalSignature.GetEncryptionAlgorithm());

            byte[] encodedSig = sgn.GetEncodedPKCS7(hash, cal, tsaClient, ocsp, crlBytes, sigtype);

            if (estimatedSize < encodedSig.Length)
                throw new IOException("Not enough space");

            byte[] paddedSig = new byte[estimatedSize];
            System.Array.Copy(encodedSig, 0, paddedSig, 0, encodedSig.Length);

            PdfDictionary dic2 = new PdfDictionary();
            dic2.Put(PdfName.CONTENTS, new PdfString(paddedSig).SetHexWriting(true));
            sap.Close(dic2);
        }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:77,代码来源:MakeSignature.cs

示例3: 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

示例4: Timestamp

        /**
         * Signs a document with a PAdES-LTV Timestamp. The document is closed at the end.
         * @param sap the signature appearance
         * @param tsa the timestamp generator
         * @param signatureName the signature name or null to have a name generated
         * automatically
         * @throws Exception
         */
        public static void Timestamp(PdfSignatureAppearance sap, ITSAClient tsa, String signatureName) {
            int contentEstimated = tsa.GetTokenSizeEstimate();
            sap.AddDeveloperExtension(PdfDeveloperExtension.ESIC_1_7_EXTENSIONLEVEL5);
            sap.SetVisibleSignature(new Rectangle(0,0,0,0), 1, signatureName);

            PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, PdfName.ETSI_RFC3161);
            dic.Put(PdfName.TYPE, PdfName.DOCTIMESTAMP);
            sap.CryptoDictionary = dic;

            Dictionary<PdfName,int> exc = new Dictionary<PdfName,int>();
            exc[PdfName.CONTENTS] = contentEstimated * 2 + 2;
            sap.PreClose(exc);
            Stream data = sap.GetRangeStream();
            IDigest messageDigest = tsa.GetMessageDigest();
            byte[] buf = new byte[4096];
            int n;
            while ((n = data.Read(buf, 0, buf.Length)) > 0) {
                messageDigest.BlockUpdate(buf, 0, n);
            }
            byte[] tsImprint = new byte[messageDigest.GetDigestSize()];
            messageDigest.DoFinal(tsImprint, 0);
            byte[] tsToken;
            try {
        	    tsToken = tsa.GetTimeStampToken(tsImprint);
            }
            catch(Exception e) {
        	    throw new GeneralSecurityException(e.Message);
            }
            if (contentEstimated + 2 < tsToken.Length)
                throw new IOException("Not enough space");

            byte[] paddedSig = new byte[contentEstimated];
            System.Array.Copy(tsToken, 0, paddedSig, 0, tsToken.Length);

            PdfDictionary dic2 = new PdfDictionary();
            dic2.Put(PdfName.CONTENTS, new PdfString(paddedSig).SetHexWriting(true));
            sap.Close(dic2);
        }
开发者ID:joshaxey,项目名称:Simple-PDFMerge,代码行数:46,代码来源:LtvTimestamp.cs

示例5: SignExternalContainer

        /**
         * Sign the document using an external container, usually a PKCS7. The signature is fully composed
         * externally, iText will just put the container inside the document.
         * @param sap the PdfSignatureAppearance
         * @param externalSignatureContainer the interface providing the actual signing
         * @param estimatedSize the reserved size for the signature
         * @throws GeneralSecurityException
         * @throws IOException
         * @throws DocumentException 
         */
        public static void SignExternalContainer(PdfSignatureAppearance sap, IExternalSignatureContainer externalSignatureContainer, int estimatedSize) {
            PdfSignature dic = new PdfSignature(null, null);
            dic.Reason = sap.Reason;
            dic.Location = sap.Location;
            dic.SignatureCreator = sap.SignatureCreator;
            dic.Contact = sap.Contact;
            dic.Date = new PdfDate(sap.SignDate); // time-stamp will over-rule this
            externalSignatureContainer.ModifySigningDictionary(dic);
            sap.CryptoDictionary = dic;

            Dictionary<PdfName, int> exc = new Dictionary<PdfName, int>();
            exc[PdfName.CONTENTS] = estimatedSize * 2 + 2;
            sap.PreClose(exc);

            Stream data = sap.GetRangeStream();
            byte[] encodedSig = externalSignatureContainer.Sign(data);

            if (estimatedSize < encodedSig.Length)
                throw new IOException("Not enough space");

            byte[] paddedSig = new byte[estimatedSize];
            System.Array.Copy(encodedSig, 0, paddedSig, 0, encodedSig.Length);

            PdfDictionary dic2 = new PdfDictionary();
            dic2.Put(PdfName.CONTENTS, new PdfString(paddedSig).SetHexWriting(true));
            sap.Close(dic2);
        }
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:37,代码来源:MakeSignature.cs

示例6: ParseInlineImageDictionary

        /**
         * Parses the next inline image dictionary from the parser.  The parser must be positioned immediately following the EI operator.
         * The parser will be left with position immediately following the whitespace character that follows the ID operator that ends the inline image dictionary.
         * @param ps the parser to extract the embedded image information from
         * @return the dictionary for the inline image, with any abbreviations converted to regular image dictionary keys and values
         * @throws IOException if the parse fails
         */
        private static PdfDictionary ParseInlineImageDictionary(PdfContentParser ps) {
            // by the time we get to here, we have already parsed the BI operator
            PdfDictionary dictionary = new PdfDictionary();
            
            for (PdfObject key = ps.ReadPRObject(); key != null && !"ID".Equals(key.ToString()); key = ps.ReadPRObject()){
                PdfObject value = ps.ReadPRObject();

                PdfName resolvedKey;
                inlineImageEntryAbbreviationMap.TryGetValue((PdfName)key, out resolvedKey);
                if (resolvedKey == null)
                    resolvedKey = (PdfName)key;

                dictionary.Put(resolvedKey, GetAlternateValue(resolvedKey, value));
            }

            int ch = ps.GetTokeniser().Read();
            if (!PRTokeniser.IsWhitespace(ch))
                throw new IOException("Unexpected character " + ch + " found after ID in inline image");
            
            return dictionary;
        }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例7: ConvertToXObject

     /**
      * Converts an annotation structure item to a Form XObject annotation.
      * @param item the structure item
      * @throws IOException
      */
     virtual protected void ConvertToXObject(StructureObject item) {
         PdfDictionary structElem = item.GetStructElem();
         if (structElem == null)
             return;
         PdfDictionary dict =  item.GetObjAsDict();
         if (dict == null || !dict.CheckType(PdfName.ANNOT))
             return;
         PdfDictionary ap = dict.GetAsDict(PdfName.AP);
         if (ap == null)
             return;
         PdfNumber structParent = dict.GetAsNumber(PdfName.STRUCTPARENT);
         if (structParent == null)
             return;
         PdfStream stream = ap.GetAsStream(PdfName.N);
         if (stream == null)
             return;
         stream.Put(PdfName.STRUCTPARENT, structParent);
         PdfIndirectReference xobjr = ap.GetAsIndirectObject(PdfName.N);
         if (xobjr == null)
             return;
         // remove the annotation from the page
 	    for (int i = 0; i < annots.Length; i++) {
 		    PdfIndirectReference annotref = annots.GetAsIndirectObject(i);
 		    if (item.GetObjRef().Number == annotref.Number) {
 			    annots.Remove(i);
 			    break;
 		    }
 	    }
 	    // replace the existing attributes by a PrintField attribute
         PdfDictionary attribute = new PdfDictionary();
         attribute.Put(PdfName.O, PdfName.PRINTFIELD);
         PdfString description = dict.GetAsString(PdfName.TU);
         if (description == null)
             description = dict.GetAsString(PdfName.T);
         if (PdfName.BTN.Equals(dict.Get(PdfName.FT))) {
             PdfNumber fflags = dict.GetAsNumber(PdfName.FF);
             if (fflags != null) {
                 int ff = fflags.IntValue;
                 if ((ff & PdfFormField.FF_PUSHBUTTON) != 0)
                     attribute.Put(PdfName.ROLE, PdfName.PB);
                 // I don't think the condition below will ever be true
                 if ((ff & PdfFormField.FF_RADIO) != 0)
                     attribute.Put(PdfName.ROLE, PdfName.rb);
                 else
                     attribute.Put(PdfName.ROLE, PdfName.CB);
             }
         }
         else {
             attribute.Put(PdfName.ROLE, PdfName.TV);
         }
         attribute.Put(PdfName.DESC, description);
         // Updating the values of the StructElem dictionary
         PdfString t = structElem.GetAsString(PdfName.T);
         if (t == null || t.ToString().Trim().Length == 0)
             structElem.Put(PdfName.T, dict.GetAsString(PdfName.T));
         structElem.Put(PdfName.A, attribute);
         structElem.Put(PdfName.S, PdfName.P);
         structElem.Put(PdfName.PG, pageref);
       	// Defining a new MCID
        	int mcid = items.ProcessMCID(structParents, item.GetRef());
         LOGGER.Info("Using MCID " + mcid);
         structElem.Put(PdfName.K, new PdfNumber(mcid));
         // removing the annotation from the parent tree
         items.RemoveFromParentTree(structParent);
         // Adding the XObject to the page
         PdfName xobj = new PdfName("XObj" + structParent.IntValue);
         LOGGER.Info("Creating XObject with name " + xobj);
         xobjects.Put(xobj, xobjr);
         PdfArray array = dict.GetAsArray(PdfName.RECT);
         // Getting the position of the annotation
         Rectangle rect = new Rectangle(
             array.GetAsNumber(0).FloatValue, array.GetAsNumber(1).FloatValue,
             array.GetAsNumber(2).FloatValue, array.GetAsNumber(3).FloatValue);
         rect.Normalize();
         // A Do operator is forbidden inside a text block
         if (inText && !btWrite) {
             LOGGER.Debug("Introducing extra ET");
             byte[] bytes = Encoding.ASCII.GetBytes("ET\n");
             baos.Write(bytes, 0, bytes.Length);
             etExtra = true;
         }
 	    // Writing the marked-content sequence with the Do operator
 	    // Note that the position assumes that the CTM wasn't changed in the graphics state
 	    // TODO: do the math if the CTM did change!
         ByteBuffer buf = new ByteBuffer();
         buf.Append("/P <</MCID ");
         buf.Append(mcid);
         buf.Append(">> BDC\n");
         buf.Append("q 1 0 0 1 ");
         buf.Append(rect.Left.ToString(CultureInfo.InvariantCulture));
         buf.Append(" ");
         buf.Append(rect.Bottom.ToString(CultureInfo.InvariantCulture));
         buf.Append(" cm ");
         buf.Append(xobj.GetBytes());
         buf.Append(" Do Q\n");
//.........这里部分代码省略.........
开发者ID:newlysoft,项目名称:itextsharp,代码行数:101,代码来源:MCParser.cs

示例8: 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

示例9: GetImage

 Image GetImage()
 {
     ReadPng();
     int pal0 = 0;
     int palIdx = 0;
     palShades = false;
     if (trans != null) {
         for (int k = 0; k < trans.Length; ++k) {
             int n = trans[k] & 0xff;
             if (n == 0) {
                 ++pal0;
                 palIdx = k;
             }
             if (n != 0 && n != 255) {
                 palShades = true;
                 break;
             }
         }
     }
     if ((colorType & 4) != 0)
         palShades = true;
     genBWMask = (!palShades && (pal0 > 1 || transRedGray >= 0));
     if (!palShades && !genBWMask && pal0 == 1) {
         additional.Put(PdfName.MASK, new PdfLiteral("["+palIdx+" "+palIdx+"]"));
     }
     bool needDecode = (interlaceMethod == 1) || (bitDepth == 16) || ((colorType & 4) != 0) || palShades || genBWMask;
     switch (colorType) {
         case 0:
             inputBands = 1;
             break;
         case 2:
             inputBands = 3;
             break;
         case 3:
             inputBands = 1;
             break;
         case 4:
             inputBands = 2;
             break;
         case 6:
             inputBands = 4;
             break;
     }
     if (needDecode)
         DecodeIdat();
     int components = inputBands;
     if ((colorType & 4) != 0)
         --components;
     int bpc = bitDepth;
     if (bpc == 16)
         bpc = 8;
     Image img;
     if (image != null) {
         if (colorType == 3)
             img = new ImgRaw(width, height, components, bpc, image);
         else
             img = Image.GetInstance(width, height, components, bpc, image);
     }
     else {
         img = new ImgRaw(width, height, components, bpc, idat.ToArray());
         img.Deflated = true;
         PdfDictionary decodeparms = new PdfDictionary();
         decodeparms.Put(PdfName.BITSPERCOMPONENT, new PdfNumber(bitDepth));
         decodeparms.Put(PdfName.PREDICTOR, new PdfNumber(15));
         decodeparms.Put(PdfName.COLUMNS, new PdfNumber(width));
         decodeparms.Put(PdfName.COLORS, new PdfNumber((colorType == 3 || (colorType & 2) == 0) ? 1 : 3));
         additional.Put(PdfName.DECODEPARMS, decodeparms);
     }
     if (additional.Get(PdfName.COLORSPACE) == null)
         additional.Put(PdfName.COLORSPACE, GetColorspace());
     if (intent != null)
         additional.Put(PdfName.INTENT, intent);
     if (additional.Size > 0)
         img.Additional = additional;
     if (icc_profile != null)
         img.TagICC = icc_profile;
     if (palShades) {
         Image im2 = Image.GetInstance(width, height, 1, 8, smask);
         im2.MakeMask();
         img.ImageMask = im2;
     }
     if (genBWMask) {
         Image im2 = Image.GetInstance(width, height, 1, 1, smask);
         im2.MakeMask();
         img.ImageMask = im2;
     }
     img.SetDpi(dpiX, dpiY);
     img.XYRatio = XYRatio;
     img.OriginalType = Image.ORIGINAL_PNG;
     return img;
 }
开发者ID:pixelia-es,项目名称:RazorPDF2,代码行数:91,代码来源:PngImage.cs

示例10: 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


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