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

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

public static GetInstance ( Stream file ) : ICC_Profile
file Stream
Результат ICC_Profile
        public static ICC_Profile GetInstance(Stream file)
        {
            byte[] head = new byte[128];
            int remain = head.Length;
            int ptr = 0;
            while (remain > 0) {
                int n = file.Read(head, ptr, remain);
                if (n <= 0)
                    throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.icc.profile"));
                remain -= n;
                ptr += n;
            }
            if (head[36] != 0x61 || head[37] != 0x63
                || head[38] != 0x73 || head[39] != 0x70)
                throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.icc.profile"));
            remain = ((head[0] & 0xff) << 24) | ((head[1] & 0xff) << 16)
                      | ((head[2] & 0xff) <<  8) | (head[3] & 0xff);
            byte[] icc = new byte[remain];
            System.Array.Copy(head, 0, icc, 0, head.Length);
            remain -= head.Length;
            ptr = head.Length;
            while (remain > 0) {
                int n = file.Read(icc, ptr, remain);
                if (n <= 0)
                    throw new ArgumentException(MessageLocalization.GetComposedMessage("invalid.icc.profile"));
                remain -= n;
                ptr += n;
            }
            return GetInstance(icc);
        }

Same methods

ICC_Profile::GetInstance ( String fname ) : ICC_Profile
ICC_Profile::GetInstance ( byte data ) : ICC_Profile
ICC_Profile::GetInstance ( byte data, int numComponents ) : 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));
                }
            }
        }