コード例 #1
0
        /// <summary>
        ///    Constructs and initializes a new instance of <see
        ///    cref="Picture" /> by reading in the contents of a
        ///    specified file abstraction.
        /// </summary>
        /// <param name="abstraction">
        ///    A <see cref="File.IFileAbstraction"/> object containing
        ///    abstraction of the file to read.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///    <paramref name="abstraction" /> is <see langword="null"
        ///    />.
        /// </exception>
        public Picture(File.IFileAbstraction abstraction)
        {
            if (abstraction == null)
            {
                throw new ArgumentNullException("abstraction");
            }

            Data        = ByteVector.FromFile(abstraction);
            filename    = abstraction.Name;
            description = abstraction.Name;

            if (!string.IsNullOrEmpty(filename) && filename.Contains("."))
            {
                mime_type = GetMimeFromExtension(filename);
                type      = mime_type.StartsWith("image/") ? PictureType.FrontCover : PictureType.NotAPicture;
            }
            else
            {
                string ext = GetExtensionFromData(data);
                MimeType = GetMimeFromExtension(ext);
                if (ext != null)
                {
                    type     = PictureType.FrontCover;
                    filename = description = "cover" + ext;
                }
                else
                {
                    type     = PictureType.NotAPicture;
                    filename = "UnknownType";
                }
            }
        }
コード例 #2
0
 public Picture(File.IFileAbstraction abstraction)
 {
     if (abstraction == null)
     {
         throw new ArgumentNullException("abstraction");
     }
     Data = ByteVector.FromFile(abstraction);
     FillInMimeFromData();
     Description = abstraction.Name;
 }
コード例 #3
0
        /// <summary>
        ///    Constructs and initializes a new instance of <see
        ///    cref="Picture" /> by reading in the contents of a
        ///    specified file abstraction.
        /// </summary>
        /// <param name="abstraction">
        ///    A <see cref="File.IFileAbstraction"/> object containing
        ///    abstraction of the file to read.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///    <paramref name="abstraction" /> is <see langword="null"
        ///    />.
        /// </exception>
        public Picture(File.IFileAbstraction abstraction)
        {
            if (abstraction == null)
            {
                throw new ArgumentNullException("abstraction");
            }

            Data        = ByteVector.FromFile(abstraction);
            filename    = abstraction.Name;
            description = abstraction.Name;

            if (!string.IsNullOrEmpty(filename) && filename.Contains("."))
            {
                FillInMimeFromExt();
            }
            else
            {
                FillInMimeFromData();
            }
        }