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
|
|
@ -19,15 +19,7 @@ namespace LibationWinForms.GridView
|
|||
|
||||
public void SetCoverArt(byte[] cover)
|
||||
{
|
||||
try
|
||||
{
|
||||
pictureBox1.Image = Dinah.Core.WindowsDesktop.Drawing.ImageReader.ToImage(cover);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "Error loading cover art for {file}", PictureFileName);
|
||||
pictureBox1.Image = Properties.Resources.default_cover_500x500;
|
||||
}
|
||||
pictureBox1.Image = WinFormsUtil.TryLoadImageOrDefault(cover);
|
||||
}
|
||||
|
||||
#region Make the form's aspect ratio always match the picture's aspect ratio.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using DataLayer;
|
||||
using Dinah.Core.WindowsDesktop.Drawing;
|
||||
using LibationUiBase.GridView;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace LibationWinForms.GridView
|
||||
|
|
@ -14,23 +12,12 @@ namespace LibationWinForms.GridView
|
|||
private WinFormsEntryStatus(LibraryBook libraryBook) : base(libraryBook) { }
|
||||
public static EntryStatus Create(LibraryBook libraryBook) => new WinFormsEntryStatus(libraryBook);
|
||||
|
||||
protected override object LoadImage(byte[] picture)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ImageReader.ToImage(picture);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "Error loading cover art for {Book}", Book);
|
||||
return Properties.Resources.default_cover_80x80;
|
||||
}
|
||||
}
|
||||
protected override Image LoadImage(byte[] picture)
|
||||
=> WinFormsUtil.TryLoadImageOrDefault(picture, LibationFileManager.PictureSize._80x80);
|
||||
|
||||
protected override Image GetResourceImage(string rescName)
|
||||
{
|
||||
var image = Properties.Resources.ResourceManager.GetObject(rescName);
|
||||
|
||||
return image as Bitmap;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue