2016-09-03 139 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));