diff --git a/Sources/Stylophone.Common/Services/AlbumArtService.cs b/Sources/Stylophone.Common/Services/AlbumArtService.cs index 0866df0..5f627e5 100644 --- a/Sources/Stylophone.Common/Services/AlbumArtService.cs +++ b/Sources/Stylophone.Common/Services/AlbumArtService.cs @@ -246,14 +246,26 @@ internal async Task LoadImageFromFile(string fileName) private SKBitmap ImageFromBytes(byte[] bytes) { - SKBitmap image = SKBitmap.Decode(bytes); + try + { + SKBitmap image = SKBitmap.Decode(bytes); - // Resize overly large images to reduce OOM risk. Is 2048 too small ? - if (image.Width > 2048) + if (image == null) + return null; + + // Resize overly large images to reduce OOM risk. Is 2048 too small ? + if (image.Width > 2048) + { + image.Resize(new SKImageInfo(2048, 2048 * image.Height / image.Width), SKFilterQuality.High); + } + return image; + } + catch (Exception e) { - image.Resize(new SKImageInfo(2048, 2048 * image.Height / image.Width), SKFilterQuality.High); + Debug.WriteLine("Exception caught while loading albumart from MPD response: " + e); + _notificationService.ShowErrorNotification(e); + return null; } - return image; } } diff --git a/Sources/Stylophone/Views/SettingsPage.xaml b/Sources/Stylophone/Views/SettingsPage.xaml index 44220db..0be3e18 100644 --- a/Sources/Stylophone/Views/SettingsPage.xaml +++ b/Sources/Stylophone/Views/SettingsPage.xaml @@ -97,7 +97,7 @@ OffContent="" OnContent="" /> - + @@ -110,7 +110,7 @@ SpinButtonPlacementMode="Compact" Value="{x:Bind ViewModel.LocalPlaybackPort, Mode=TwoWay}" /> - +