示例#1
0
        protected override Properties ExtractProperties()
        {
            int    width = 0, height = 0;
            IFDTag tag = GetTag(TagTypes.TiffIFD)
                         as IFDTag;
            IFDStructure structure = tag.Structure;
            var          sub_ifds  = structure.GetEntry(0, (ushort)IFDEntryTag.SubIFDs)
                                     as SubIFDArrayEntry;

            if (sub_ifds == null)
            {
                return(base.ExtractProperties());
            }
            foreach (var entry in sub_ifds.Entries)
            {
                var type = entry.GetLongValue(0, (ushort)IFDEntryTag.NewSubfileType);
                if (type == 0)
                {
                    width  = (int)(entry.GetLongValue(0, (ushort)IFDEntryTag.ImageWidth) ?? 0);
                    height = (int)(entry.GetLongValue(0, (ushort)IFDEntryTag.ImageLength) ?? 0);
                    break;
                }
            }
            if (width > 0 && height > 0)
            {
                return(new Properties(TimeSpan.Zero, CreateCodec(width, height)));
            }
            return(base.ExtractProperties());
        }
示例#2
0
        /// <summary>
        ///    Attempts to extract the media properties of the main
        ///    photo.
        /// </summary>
        /// <returns>
        ///    A <see cref="Properties" /> object with a best effort guess
        ///    at the right values. When no guess at all can be made,
        ///    <see langword="null" /> is returned.
        /// </returns>
        protected override Properties ExtractProperties()
        {
            int width = 0, height = 0;

            IFDTag       tag       = GetTag(TagTypes.TiffIFD) as IFDTag;
            IFDStructure structure = tag.Structure;

            // DNG uses SubIFDs for images, the one with SubfileType = 0 is the RAW data.
            var sub_ifds = structure.GetEntry(0, (ushort)IFDEntryTag.SubIFDs) as SubIFDArrayEntry;

            if (sub_ifds == null)
            {
                return(base.ExtractProperties());
            }

            foreach (var entry in sub_ifds.Entries)
            {
                var type = entry.GetLongValue(0, (ushort)IFDEntryTag.NewSubfileType);
                if (type == 0)
                {
                    width  = (int)(entry.GetLongValue(0, (ushort)IFDEntryTag.ImageWidth) ?? 0);
                    height = (int)(entry.GetLongValue(0, (ushort)IFDEntryTag.ImageLength) ?? 0);
                    break;                     // No need to iterate the other SubIFDs
                }
            }

            if (width > 0 && height > 0)
            {
                return(new Properties(TimeSpan.Zero, CreateCodec(width, height)));
            }

            // Fall back to normal detection.
            return(base.ExtractProperties());
        }