小编Ovi*_*n08的帖子

使用TagLib sharp加载相册艺术,然后将其保存到C#中的相同/不同文件会导致内存错误

我的应用程序列出目录中的所有MP3,当用户选择文件时,它会加载标签信息,包括专辑封面.将该艺术加载到用户保存数据时使用的变量中.该艺术品也被加载到图片框中供用户查看.

// Global to all methods
System.Drawing.Image currentImage = null;

// In method onclick of the listbox showing all mp3's
TagLib.File f = new TagLib.Mpeg.AudioFile(file);
if (f.Tag.Pictures.Length > 0)
{
      TagLib.IPicture pic = f.Tag.Pictures[0];
      MemoryStream ms = new MemoryStream(pic.Data.Data);
      if (ms != null && ms.Length > 4096)
      {
           currentImage = System.Drawing.Image.FromStream(ms);
           // Load thumbnail into PictureBox
           AlbumArt.Image = currentImage.GetThumbnailImage(100,100, null, System.IntPtr.Zero);
      }
      ms.Close();
}

// Method to save album art
TagLib.Picture pic = new TagLib.Picture();
pic.Type = TagLib.PictureType.FrontCover;
pic.MimeType = …
Run Code Online (Sandbox Code Playgroud)

c# mp3 taglib

5
推荐指数
1
解决办法
5646
查看次数

标签 统计

c# ×1

mp3 ×1

taglib ×1