From 8a2274fc0811682e1ff5c9e68cc1feb63998a370 Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Sun, 3 Apr 2022 01:51:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9C=E5=9B=BE=E7=89=87=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=B8=BAwebp=E6=97=B6=E6=97=A0=E6=B3=95=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=EF=BC=8C=E6=8D=95=E8=8E=B7=E6=AD=A4=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=EF=BC=8C=E6=9C=AA=E8=A7=A3=E5=86=B3=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/Storage/StorageCover.cs | 26 ++++++++++++++++++++++--- DownKyi.Core/Storage/StorageHeader.cs | 28 +++++++++++++++++++++++---- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/DownKyi.Core/Storage/StorageCover.cs b/DownKyi.Core/Storage/StorageCover.cs index eb0a115..13aa340 100644 --- a/DownKyi.Core/Storage/StorageCover.cs +++ b/DownKyi.Core/Storage/StorageCover.cs @@ -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; + } } /// diff --git a/DownKyi.Core/Storage/StorageHeader.cs b/DownKyi.Core/Storage/StorageHeader.cs index a0d3077..5a89e99 100644 --- a/DownKyi.Core/Storage/StorageHeader.cs +++ b/DownKyi.Core/Storage/StorageHeader.cs @@ -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; + } } /// @@ -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) {