Ejemplo n.º 1
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>
        private Properties ExtractProperties()
        {
            int width = 0, height = 0;

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

            width  = (int)(structure.GetLongValue(0, 0x07) ?? 0);
            height = (int)(structure.GetLongValue(0, 0x06) ?? 0);

            var vendor = ImageTag.Make;

            if (vendor == "LEICA")
            {
                vendor = "Leica";
            }
            var desc = String.Format("{0} RAW File", vendor);

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

            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///    Gets a tag of a specified type from the current instance,
        ///    optionally creating a new tag if possible.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="TagLib.TagTypes" /> value indicating the
        ///    type of tag to read.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> value specifying whether or not to
        ///    try and create the tag if one is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="Tag" /> object containing the tag that was
        ///    found in or added to the current instance. If no
        ///    matching tag was found and none was created, <see
        ///    langword="null" /> is returned.
        /// </returns>
        public override Tag GetTag (TagTypes type, bool create)
        {
            Tag tag = base.GetTag (type, false);
            if (tag != null) {
                return tag;
            }

            if (!create || (type & ImageTag.AllowedTypes) == 0)
                return null;

            if (type != TagTypes.TiffIFD)
                return base.GetTag (type, create);

            ImageTag new_tag = new IFDTag (this);
            ImageTag.AddTag (new_tag);
            return new_tag;
        }