public ID3v2ImageFrame(BinaryReader reader) : base(reader) { long headerStartPosition = reader.BaseStream.Position; this.mimeType = ReadText(reader, Encoding.ASCII); this.imageType = (ID3v2ImageType)reader.ReadByte(); this.description = ReadText(reader, Encoding); long headerEndPosition = reader.BaseStream.Position; long imageDataLength = ParsedDataLength - base.DataLength - (headerEndPosition - headerStartPosition); if (imageDataLength < 0) { throw new InvalidDataException(string.Format("Invalid image data length '{0}'.", imageDataLength)); } this.imageData = reader.ReadBytes((int)imageDataLength); string dataMimeType = GetMimeType(this.imageData); if (this.mimeType != dataMimeType) { this.mimeType = dataMimeType; this.hasChanged = true; } }
public ID3v2ImageFrame(IEnumerable <byte> imageData) : base("APIC", 0) { if (imageData == null) { throw new ArgumentNullException("imageData"); } this.mimeType = GetMimeType(imageData); this.imageType = ID3v2ImageType.FrontCover; this.description = string.Empty; this.imageData = imageData.ToArray(); }
public ID3v2ImageFrame(string mimeType, ID3v2ImageType imageType, string description, IEnumerable <byte> imageData) : base("APIC", 1) { if (mimeType == null) { throw new ArgumentNullException("mimeType"); } if (description == null) { throw new ArgumentNullException("description"); } if (imageData == null) { throw new ArgumentNullException("imageData"); } this.mimeType = mimeType; this.imageType = imageType; this.description = description; this.imageData = imageData.ToArray(); }