2016-09-03 30 views
0

我试图修改我的歌曲的元数据。我得到了这个工作,但如果用户没有指定专辑图像,我会自动从持有专辑图像的图片盒中绘制一张。返回的图像真的很模糊 - 有什么办法可以使它尽可能高清晰?这里就是我搞定我的代码的一部分:如何将此图像保存为HD?

if (isDir == false){ 
      IPicture art2 = new TagLib.Picture(new TagLib.ByteVector((byte[])new System.Drawing.ImageConverter().ConvertTo(pictureBox1.Image, typeof(byte[])))); //I make the new picture here. 

      TagLib.File file2 = TagLib.File.Create(Properties.Settings.Default.NowPlayingPath); 
      file2.Tag.Title = SongBox.Text; 
      file2.Tag.AlbumArtists = artist; 
      file2.Tag.Genres = genre; 
      file2.Tag.Year = Convert.ToUInt32(YearBox.Text); 
      file2.Tag.Composers = composers; 
      file2.Tag.Pictures = new IPicture[1] { art2 };//I set the picture here. 
      file2.Save(); 
      MessageBox.Show("You'll need to reload your song to continue listening to it.", "Settings saved."); 
      this.Hide(); 
     } 
    } 

回答

1

尝试使用MemoryStream获得的图像作为字节数组:

MemoryStream ms = new MemoryStream(); 
pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); 
byte[] buff = ms.GetBuffer(); 
IPicture art2 = new TagLib.Picture(new TagLib.ByteVector(buff));