如果图片格式为webp时无法加载,捕获此异常,未解决问题

croire 3 years ago
parent cb2a6055a4
commit 8a2274fc08

@ -44,10 +44,30 @@ namespace DownKyi.Core.Storage
{
if (cover == null) { return null; }
Bitmap bitmap = new Bitmap(cover);
Image thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero);
try
{
Bitmap bitmap = new Bitmap(cover);
Image thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero);
return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail));
}
catch (ArgumentException e)
{
Utils.Debugging.Console.PrintLine(cover);
Utils.Debugging.Console.PrintLine("GetCoverThumbnail()发生异常: {0}", e);
LogManager.Error("StorageCover.GetCoverThumbnail()", cover);
LogManager.Error("StorageCover.GetCoverThumbnail()", e);
return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail));
return null;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetCoverThumbnail()发生异常: {0}", e);
LogManager.Error("StorageCover.GetCoverThumbnail()", e);
return null;
}
}
/// <summary>

@ -44,10 +44,30 @@ namespace DownKyi.Core.Storage
{
if (header == null) { return null; }
var bitmap = new Bitmap(header);
var thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero);
try
{
Bitmap bitmap = new Bitmap(header);
Image thumbnail = bitmap.GetThumbnailImage(width, height, null, IntPtr.Zero);
return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail));
}
catch (ArgumentException e)
{
Utils.Debugging.Console.PrintLine(header);
Utils.Debugging.Console.PrintLine("GetHeaderThumbnail()发生异常: {0}", e);
LogManager.Error("StorageHeader.GetHeaderThumbnail()", header);
LogManager.Error("StorageHeader.GetHeaderThumbnail()", e);
return StorageUtils.BitmapToBitmapImage(new Bitmap(thumbnail));
return null;
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("GetHeaderThumbnail()发生异常: {0}", e);
LogManager.Error("StorageHeader.GetHeaderThumbnail()", e);
return null;
}
}
/// <summary>
@ -58,7 +78,7 @@ namespace DownKyi.Core.Storage
public string GetHeader(long mid, string name, string url)
{
HeaderDb headerDb = new HeaderDb();
var header = headerDb.QueryByMid(mid);
Header header = headerDb.QueryByMid(mid);
if (header != null)
{

Loading…
Cancel
Save