/// <summary> /// 通过文件地址获取Tag(歌曲歌手图片(内置)) /// </summary> /// <param name="MusicPath">歌曲路径</param> /// <returns></returns> public List <Image> GetPic_Music(string MusicPath) { List <Image> imgList = new List <Image>(); Tags.ID3.ID3Info file = new Tags.ID3.ID3Info(MusicPath, true); foreach (Tags.ID3.ID3v2Frames.BinaryFrames.AttachedPictureFrame item in file.ID3v2Info.AttachedPictureFrames) { System.Drawing.Image img = item.Picture; // 此段代码用于将获得的 imgList.Add(img); } return(imgList); }
public static void thumbnailProcessor__audio(string path, string vitemid) { #if UBERMEDIA try { Tags.ID3.ID3Info i = new Tags.ID3.ID3Info(path, true); // Ensure data and pictures were found if (i.HaveException || !i.ID3v2Info.HaveTag || i.ID3v2Info.AttachedPictureFrames.Count == 0) { return; } Image img = i.ID3v2Info.AttachedPictureFrames[0].Picture; Bitmap thumbnail = new Bitmap(Core.settings[Base.SETTINGS_KEY].getInt(Base.SETTINGS_THUMBNAIL_WIDTH), Core.settings[Base.SETTINGS_KEY].getInt(Base.SETTINGS_THUMBNAIL_HEIGHT)); Graphics g = Graphics.FromImage(thumbnail); g.FillRectangle(new SolidBrush(Color.Black), 0, 0, thumbnail.Width, thumbnail.Height); double fitToThumbnailRatio = (img.Width > img.Height ? (double)thumbnail.Width / (double)img.Width : (double)thumbnail.Height / (double)img.Height); Rectangle drawArea = new Rectangle(); drawArea.Width = (int)(fitToThumbnailRatio * (double)img.Width); drawArea.Height = (int)(fitToThumbnailRatio * (double)img.Height); drawArea.X = (int)(((double)thumbnail.Width - (double)drawArea.Width) / 2); drawArea.Y = (int)(((double)thumbnail.Height - (double)drawArea.Height) / 2); g.DrawImage(img, drawArea); g.Dispose(); // Convert to a byte array MemoryStream ms = new MemoryStream(); thumbnail.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); thumbnail.Dispose(); img.Dispose(); byte[] data = ms.ToArray(); ms.Dispose(); // Upload to the database Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("thumbnail", data); parameters.Add("vitemid", vitemid); Core.globalConnector.Query_Execute_Parameters("UPDATE um_virtual_items SET thumbnail_data=@thumbnail WHERE vitemid=@vitemid", parameters); } catch { } #endif }
public static void thumbnailProcessor__audio(string path, string vitemid) { #if UBERMEDIA try { Tags.ID3.ID3Info i = new Tags.ID3.ID3Info(path, true); // Ensure data and pictures were found if (i.HaveException || !i.ID3v2Info.HaveTag || i.ID3v2Info.AttachedPictureFrames.Count == 0) return; Image img = i.ID3v2Info.AttachedPictureFrames[0].Picture; Bitmap thumbnail = new Bitmap(Core.settings[Base.SETTINGS_KEY].getInt(Base.SETTINGS_THUMBNAIL_WIDTH), Core.settings[Base.SETTINGS_KEY].getInt(Base.SETTINGS_THUMBNAIL_HEIGHT)); Graphics g = Graphics.FromImage(thumbnail); g.FillRectangle(new SolidBrush(Color.Black), 0, 0, thumbnail.Width, thumbnail.Height); double fitToThumbnailRatio = (img.Width > img.Height ? (double)thumbnail.Width / (double)img.Width : (double)thumbnail.Height / (double)img.Height); Rectangle drawArea = new Rectangle(); drawArea.Width = (int)(fitToThumbnailRatio * (double)img.Width); drawArea.Height = (int)(fitToThumbnailRatio * (double)img.Height); drawArea.X = (int)(((double)thumbnail.Width - (double)drawArea.Width) / 2); drawArea.Y = (int)(((double)thumbnail.Height - (double)drawArea.Height) / 2); g.DrawImage(img, drawArea); g.Dispose(); // Convert to a byte array MemoryStream ms = new MemoryStream(); thumbnail.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); thumbnail.Dispose(); img.Dispose(); byte[] data = ms.ToArray(); ms.Dispose(); // Upload to the database Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters.Add("thumbnail", data); parameters.Add("vitemid", vitemid); Core.globalConnector.Query_Execute_Parameters("UPDATE um_virtual_items SET thumbnail_data=@thumbnail WHERE vitemid=@vitemid", parameters); } catch { } #endif }
/// <summary> /// 通过文件地址获取Tag(歌曲歌手图片(内置)) /// </summary> /// <param name="MusicPath">歌曲路径</param> /// <returns></returns> public List<Image> GetPic_Music(string MusicPath) { List<Image> imgList = new List<Image>(); try { Tags.ID3.ID3Info file = new Tags.ID3.ID3Info(MusicPath, true); foreach (Tags.ID3.ID3v2Frames.BinaryFrames.AttachedPictureFrame item in file.ID3v2Info.AttachedPictureFrames) { System.Drawing.Image img = item.Picture; // 此段代码用于将获得的 imgList.Add(img); } } catch (Exception) { } return imgList; }