Fix bug where book with corrupt image cannot be queued.
This commit is contained in:
parent
245e55782e
commit
5ec01913d5
11 changed files with 58 additions and 67 deletions
23
Source/LibationWinForms/WinFormsUtil.cs
Normal file
23
Source/LibationWinForms/WinFormsUtil.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using Dinah.Core.WindowsDesktop.Drawing;
|
||||
using LibationFileManager;
|
||||
using System.Drawing;
|
||||
|
||||
namespace LibationWinForms
|
||||
{
|
||||
internal static class WinFormsUtil
|
||||
{
|
||||
private static Bitmap defaultImage;
|
||||
public static Image TryLoadImageOrDefault(byte[] picture, PictureSize defaultSize = PictureSize.Native)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ImageReader.ToImage(picture);
|
||||
}
|
||||
catch
|
||||
{
|
||||
using var ms = new System.IO.MemoryStream(PictureStorage.GetDefaultImage(defaultSize));
|
||||
return defaultImage ??= new Bitmap(ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue