/// <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"; } } }
public Picture(File.IFileAbstraction abstraction) { if (abstraction == null) { throw new ArgumentNullException("abstraction"); } Data = ByteVector.FromFile(abstraction); FillInMimeFromData(); Description = abstraction.Name; }
/// <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(); } }