带有taglib的C#mp3 ID标签 – 专辑封面
我正在制作自己的mp3标签,到目前为止一切都很好。 虽然我坚持阅读专辑艺术标签。
我想知道如何在C#.NET图片框中显示封面,但是关于该特定标签的所有内容都让我感到困惑。
我知道我可以从这样的文件中获取标签
txtAlbum.Text = currentFile.Tag.Album;
但我需要做的就是从文件中抓取图片并将其放入图片框中。 然后我想知道如何将图片(jpg,png)写入文件并覆盖现有文件。
非常感谢任何帮助,感谢您宝贵的时间。
试试这个
TagLib.File tagFile = TagLib.File.Create(path); IPicture newArt = new Picture(tmpImg); tagFile.Tag.Pictures = new IPicture[1] {newArt}; tagFile.Save();
编辑
var file = TagLib.File.Create(filename); if (file.Tag.Pictures.Length >= 1) { var bin = (byte[])(file.Tag.Pictures[0].Data.Data); PreviewPictureBox.Image = Image.FromStream(new MemoryStream(bin)).GetThumbnailImage(100, 100, null, IntPtr.Zero); }
这是我对该问题的快速而简短的解决方案:
var file = TagLib.File.Create(filename); var bin = (byte[])(file.Tag.Pictures[0].Data.Data); imageBox.Image = Image.FromStream(new MemoryStream(bin));