收藏夹中的图片使用缩略图

croire 3 years ago
parent ab97c43a8f
commit 994eb158b9

@ -30,7 +30,7 @@ namespace DownKyi.Core.Storage
{ {
string header = GetCover(avid, bvid, cid, url); string header = GetCover(avid, bvid, cid, url);
return GetGetCoverThumbnail(header, width, height); return GetCoverThumbnail(header, width, height);
} }
/// <summary> /// <summary>
@ -40,10 +40,10 @@ namespace DownKyi.Core.Storage
/// <param name="width"></param> /// <param name="width"></param>
/// <param name="height"></param> /// <param name="height"></param>
/// <returns></returns> /// <returns></returns>
public BitmapImage GetGetCoverThumbnail(string cover, int width, int height) public BitmapImage GetCoverThumbnail(string cover, int width, int height)
{ {
var bitmap = new Bitmap(cover); Bitmap bitmap = new Bitmap(cover);
var thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero); Image thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero);
return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail)); return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail));
} }
@ -69,7 +69,7 @@ namespace DownKyi.Core.Storage
public string GetCover(long avid, string bvid, long cid, string url) public string GetCover(long avid, string bvid, long cid, string url)
{ {
CoverDb coverDb = new CoverDb(); CoverDb coverDb = new CoverDb();
var cover = coverDb.QueryByUrl(url); Cover cover = coverDb.QueryByUrl(url);
// 如果存在,直接返回 // 如果存在,直接返回
// 如果不存在,则先下载 // 如果不存在,则先下载
@ -195,7 +195,7 @@ namespace DownKyi.Core.Storage
/// <returns></returns> /// <returns></returns>
public bool IsLocal(CoverDb coverDb, string url) public bool IsLocal(CoverDb coverDb, string url)
{ {
var cover = coverDb.QueryByUrl(url); Cover cover = coverDb.QueryByUrl(url);
return cover != null; return cover != null;
} }
@ -207,7 +207,7 @@ namespace DownKyi.Core.Storage
/// <returns></returns> /// <returns></returns>
public string LocalCover(CoverDb coverDb, string url) public string LocalCover(CoverDb coverDb, string url)
{ {
var cover = coverDb.QueryByUrl(url); Cover cover = coverDb.QueryByUrl(url);
return cover.Md5; return cover.Md5;
} }

@ -26,7 +26,7 @@ namespace DownKyi.Services
// 查询、保存封面 // 查询、保存封面
StorageCover storageCover = new StorageCover(); StorageCover storageCover = new StorageCover();
string coverUrl = favoritesMetaInfo.Cover; string coverUrl = favoritesMetaInfo.Cover;
string cover = storageCover.GetCover(favoritesMetaInfo.Id, "Favorites", favoritesMetaInfo.Mid, coverUrl); BitmapImage cover = storageCover.GetCoverThumbnail(favoritesMetaInfo.Id, "Favorites", favoritesMetaInfo.Mid, coverUrl, 300, 188);
// 获取用户头像 // 获取用户头像
string upName; string upName;
@ -49,7 +49,7 @@ namespace DownKyi.Services
{ {
favorites.CoverUrl = coverUrl; favorites.CoverUrl = coverUrl;
favorites.Cover = cover == null ? null : new BitmapImage(new Uri(cover)); favorites.Cover = cover;
favorites.Title = favoritesMetaInfo.Title; favorites.Title = favoritesMetaInfo.Title;
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区 DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
@ -98,7 +98,7 @@ namespace DownKyi.Services
// 查询、保存封面 // 查询、保存封面
StorageCover storageCover = new StorageCover(); StorageCover storageCover = new StorageCover();
string coverUrl = media.Cover; string coverUrl = media.Cover;
string cover = storageCover.GetCover(media.Id, media.Bvid, -1, coverUrl); BitmapImage cover = storageCover.GetCoverThumbnail(media.Id, media.Bvid, -1, coverUrl, 200, 125);
App.PropertyChangeAsync(new Action(() => App.PropertyChangeAsync(new Action(() =>
{ {
@ -107,7 +107,7 @@ namespace DownKyi.Services
Avid = media.Id, Avid = media.Id,
Bvid = media.Bvid, Bvid = media.Bvid,
Order = order, Order = order,
Cover = cover == null ? null : new BitmapImage(new Uri(cover)), Cover = cover,
Title = media.Title, Title = media.Title,
PlayNumber = media.CntInfo != null ? Format.FormatNumber(media.CntInfo.Play) : "0", PlayNumber = media.CntInfo != null ? Format.FormatNumber(media.CntInfo.Play) : "0",
DanmakuNumber = media.CntInfo != null ? Format.FormatNumber(media.CntInfo.Danmaku) : "0", DanmakuNumber = media.CntInfo != null ? Format.FormatNumber(media.CntInfo.Danmaku) : "0",
@ -120,7 +120,7 @@ namespace DownKyi.Services
if (!result.ToList().Exists(t => t.Avid == newMedia.Avid)) if (!result.ToList().Exists(t => t.Avid == newMedia.Avid))
{ {
result.Add(newMedia); result.Add(newMedia);
Thread.Sleep(50); Thread.Sleep(10);
} }
})); }));
} }

Loading…
Cancel
Save