专辑封面 - 与标签库C#MP3 ID标签 [英] C# mp3 ID tags with taglib - album art
问题描述
林让我自己的MP3标注,并且一切都很好至今。虽然IM卡读取专辑封面标签。
Im making my own mp3 tagger, and everything is fine so far. Although im stuck reading the album art tag.
我想知道如何显示在C#.NET图片框的封面,但一切IV看到关于该特定标签是困惑我。
I would like to know how to display the cover in a C#.NET picture box, but everything iv seen about that particular tag is confusing me.
我知道我可以从这样的文件,获取广告代码
I know i can get tags from files like this
txtAlbum.Text = currentFile.Tag.Album;
但我需要做的就是抓住从文件中的图片,在PictureBox捶它。然后,我想知道如何写一个图片(JPG,PNG)入档并覆盖现有之一。
but all i need to do is grab the picture from the file and whack it in a picturebox. Then i would like to know how to write a picture (jpg, png) into the file and overwrite the existing one.
任何帮助将不胜感激,谢谢你为您的宝贵时间。
Any help would be greatly appreciated, and thank you for your valued time.
推荐答案
试试这个
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);
}
这篇关于专辑封面 - 与标签库C#MP3 ID标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!