将位图作为封面的MP3 [英] Set Bitmap as cover art for MP3
本文介绍了将位图作为封面的MP3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在试图设置一个位图作为封面的MP3,但我似乎无法得到它的工作。它不抛出任何错误,但是当我播放MP3位图没有显示。
这是我目前有:
TagLib.File F = TagLib.File.Create(Song.mp3的);图片currentImage = getAlbumArt(result.passedAlbumID);
图像pic =新的图片();
pic.Type = PictureType.FrontCover;
pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
pic.Description =盖;
MemoryStream的毫秒=新的MemoryStream();
currentImage.Save(MS,System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Position = 0;
pic.Data = ByteVector.FromStream(毫秒);
f.Tag.Pictures =新IPICTURE [1] {图};
pictureBox1.Image = currentImage; //测试图像是正确的f.Save();
ms.Close();
解决方案
我用下面的code和一切工作正常,我:
TagLib.File文件= TagLib.File.Create(/ *路径,您的MP3文件* /);
TagLib.Picture PIC =新TagLib.Picture();
pic.Type = TagLib.PictureType.FrontCover;
pic.Description =盖;
pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
MemoryStream的毫秒=新的MemoryStream();
/ *图片* /保存(MS,System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Position = 0;
pic.Data = TagLib.ByteVector.FromStream(毫秒);
file.Tag.Pictures =新TagLib.IPicture [] {图};
file.Save();
ms.Close();
根据您提供的code,我唯一被注意,我的code使用下面的行
file.Tag.Pictures =新TagLib.IPicture [] {图};
而不是
f.Tag.Pictures =新TagLib.IPicture [1] {图};
所以,简单地试试,如果当你删除 1
方括号中它的工作原理。
I have been trying to set a bitmap as cover art for a MP3 but I can't seem to get it working. It isn't throwing any errors but when I play the MP3 the bitmap isn't showing.
This is what I currently have:
TagLib.File f = TagLib.File.Create("song.mp3");
Image currentImage = getAlbumArt(result.passedAlbumID);
Picture pic = new Picture();
pic.Type = PictureType.FrontCover;
pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
pic.Description = "Cover";
MemoryStream ms = new MemoryStream();
currentImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Position = 0;
pic.Data = ByteVector.FromStream(ms);
f.Tag.Pictures = new IPicture[1] { pic };
pictureBox1.Image = currentImage; //testing the image is correct
f.Save();
ms.Close();
解决方案
I'm using the following code and everything works fine for me:
TagLib.File file = TagLib.File.Create(/*path to your mp3 file*/);
TagLib.Picture pic = new TagLib.Picture();
pic.Type = TagLib.PictureType.FrontCover;
pic.Description = "Cover";
pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
MemoryStream ms = new MemoryStream();
/*your image*/.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
ms.Position = 0;
pic.Data = TagLib.ByteVector.FromStream(ms);
file.Tag.Pictures = new TagLib.IPicture[] { pic };
file.Save();
ms.Close();
According to your provided code, the only thing I noticed is, that my code is using following line
file.Tag.Pictures = new TagLib.IPicture[] { pic };
instead of
f.Tag.Pictures = new TagLib.IPicture[1] { pic };
So simply try, if it works when you remove the 1
inside the square brackets.
这篇关于将位图作为封面的MP3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文