Example #1
0
        public TagPicture(Image image, TagPicture.PICTURE_TYPE pictureType, string description)
        {
            this.PictureType = pictureType;
            this.Description = description;
            ImageConverter imageConverter = new ImageConverter();

            this.Data           = (byte[])imageConverter.ConvertTo(image, typeof(byte[]));
            this.MIMEType       = TagPicture.GetMimeTypeFromImage(image);
            this.PictureStorage = TagPicture.PICTURE_STORAGE.Internal;
        }
Example #2
0
 internal TagPicture(byte[] pData, int pType)
 {
     this.PictureStorage = TagPicture.PICTURE_STORAGE.Internal;
     if (pType == 1)
     {
         this.AttributeIndex = -1;
         this.MIMEType       = "Unknown";
         this.PictureType    = TagPicture.PICTURE_TYPE.Unknown;
         this.Description    = "";
         MemoryStream memoryStream = null;
         BinaryReader binaryReader = null;
         if (pData == null || pData.Length <= 32)
         {
             return;
         }
         try
         {
             memoryStream     = new MemoryStream(pData);
             binaryReader     = new BinaryReader(memoryStream);
             this.PictureType = (TagPicture.PICTURE_TYPE)TagPicture.ReadInt32(binaryReader);
             int count = TagPicture.ReadInt32(binaryReader);
             this.MIMEType = Encoding.UTF8.GetString(binaryReader.ReadBytes(count));
             int count2 = TagPicture.ReadInt32(binaryReader);
             this.Description = Encoding.UTF8.GetString(binaryReader.ReadBytes(count2));
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             binaryReader.ReadInt32();
             int count3 = TagPicture.ReadInt32(binaryReader);
             this.Data = binaryReader.ReadBytes(count3);
             return;
         }
         catch
         {
             return;
         }
         finally
         {
             try
             {
                 if (binaryReader != null)
                 {
                     binaryReader.Close();
                 }
                 if (memoryStream != null)
                 {
                     memoryStream.Close();
                     memoryStream.Dispose();
                 }
                 if (binaryReader != null)
                 {
                     binaryReader.Dispose();
                 }
             }
             catch
             {
             }
         }
     }
     if (pType == 2)
     {
         this.AttributeIndex = -1;
         this.MIMEType       = "Unknown";
         this.PictureType    = TagPicture.PICTURE_TYPE.Unknown;
         this.Description    = "";
         if (pData == null || pData.Length == 0)
         {
             return;
         }
         try
         {
             int num = 0;
             while (pData[num] != 0)
             {
                 num++;
             }
             this.Description = Encoding.UTF8.GetString(pData, 0, num);
             num++;
             this.Data = new byte[pData.Length - num];
             Array.Copy(pData, num, this.Data, 0, this.Data.Length);
             if (this.PictureImage != null)
             {
                 this.MIMEType = TagPicture.GetMimeTypeFromImage(this.PictureImage);
             }
             return;
         }
         catch
         {
             return;
         }
     }
     this.AttributeIndex = -1;
     this.MIMEType       = "Unknown";
     this.PictureType    = TagPicture.PICTURE_TYPE.FrontAlbumCover;
     this.Description    = "CoverArt";
     this.Data           = pData;
     if (this.PictureImage != null)
     {
         this.MIMEType = TagPicture.GetMimeTypeFromImage(this.PictureImage);
     }
 }