コード例 #1
0
            /// <summary>
            /// Initializes the item based on the specified PdfDictionary.
            /// </summary>
            /// <param name="dictionary">The dictionary to use for initialization.</param>
            private void Initialize(PdfDictionary dictionary)
            {
                if (dictionary == null)
                {
                    throw new ArgumentNullException("dictionary", "The PDF dictionary item to extract image meta data from was null.");
                }
                if (!dictionary.IsImage())
                {
                    throw new ArgumentException("The specified dictionary does not represent an image.", "dictionary");
                }

                Height       = dictionary.Elements.GetInteger("/Height");
                Width        = dictionary.Elements.GetInteger("/Width");
                BitsPerPixel = dictionary.Elements.GetInteger("/BitsPerComponent");
                Length       = dictionary.Elements.GetInteger("/Length");

                PdfItem colorSpace = null;

                if (dictionary.Elements.TryGetValue("/ColorSpace", out colorSpace))
                {
                    ColorSpace = PdfDictionaryColorSpace.Parse(colorSpace);
                }
                else
                {
                    ColorSpace = new PdfRGBColorSpace(); // Default to RGB Color Space
                }
                Compression = Compression.CCITTFAX4;
            }