This commit is contained in:
MBucari 2023-03-07 22:03:42 -07:00
parent d3607583ab
commit e76f99ff28
6 changed files with 71 additions and 35 deletions

View file

@ -9,10 +9,6 @@ namespace LibationWinForms.GridView
{
public string PictureFileName { get; set; }
public string BookSaveDirectory { get; set; }
public byte[] CoverPicture { get => _coverBytes; set => pictureBox1.Image = Dinah.Core.WindowsDesktop.Drawing.ImageReader.ToImage(_coverBytes = value); }
private byte[] _coverBytes;
public ImageDisplay()
{
@ -21,6 +17,19 @@ namespace LibationWinForms.GridView
lastHeight = Height;
}
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;
}
}
#region Make the form's aspect ratio always match the picture's aspect ratio.
private bool detectedResizeDirection = false;
@ -106,7 +115,7 @@ namespace LibationWinForms.GridView
try
{
File.WriteAllBytes(saveFileDialog.FileName, CoverPicture);
pictureBox1.Image.Save(saveFileDialog.FileName);
}
catch (Exception ex)
{