iTextSharp.text.pdf.ICC_Profile.GetInstance C# (CSharp) Метод

GetInstance() публичный статический Метод

public static GetInstance ( byte data, int numComponents ) : ICC_Profile
data byte
numComponents int
Результат ICC_Profile
        public static ICC_Profile GetInstance(byte[] data, int numComponents)
        {
            if (data.Length < 128 || data[36] != 0x61 || data[37] != 0x63
                || data[38] != 0x73 || data[39] != 0x70)
                throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.icc.profile"));
            ICC_Profile icc = new ICC_Profile();
            icc.data = data;

            if (!cstags.TryGetValue(Encoding.ASCII.GetString(data, 16, 4), out icc.numComponents)) {
                icc.numComponents = 0;
            }
            // invalid ICC
            if (icc.numComponents != numComponents) {
                throw new ArgumentException(MessageLocalization.GetComposedMessage("ICC profile contains " + icc.numComponents + " component(s), the image data contains " + numComponents + " component(s)"));
            }
            return icc;
        }

Same methods

ICC_Profile::GetInstance ( Stream file ) : ICC_Profile
ICC_Profile::GetInstance ( String fname ) : ICC_Profile
ICC_Profile::GetInstance ( byte data ) : ICC_Profile

Usage Example

Пример #1
0
        protected override void ReadColorProfile()
        {
            PdfObject outputIntents = reader.Catalog.GetAsArray(PdfName.OUTPUTINTENTS);

            if (outputIntents != null && ((PdfArray)outputIntents).Size > 0)
            {
                PdfStream iccProfileStream = null;
                for (int i = 0; i < ((PdfArray)outputIntents).Size; i++)
                {
                    PdfDictionary outputIntentDictionary = ((PdfArray)outputIntents).GetAsDict(i);
                    if (outputIntentDictionary != null)
                    {
                        PdfName gts = outputIntentDictionary.GetAsName(PdfName.S);
                        if (iccProfileStream == null || PdfName.GTS_PDFA1.Equals(gts))
                        {
                            iccProfileStream = outputIntentDictionary.GetAsStream(PdfName.DESTOUTPUTPROFILE);
                            if (iccProfileStream != null && PdfName.GTS_PDFA1.Equals(gts))
                            {
                                break;
                            }
                        }
                    }
                }
                if (iccProfileStream is PRStream)
                {
                    colorProfile = ICC_Profile.GetInstance(PdfReader.GetStreamBytes((PRStream)iccProfileStream));
                }
            }
        }