Merge pull request #869 from atravita-mods/patch-1

Add error message for invalid PNG
This commit is contained in:
Jesse Plamondon-Willard 2022-08-08 19:46:30 -04:00
commit f3ff334c08
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
1 changed files with 4 additions and 0 deletions

View File

@ -254,6 +254,10 @@ namespace StardewModdingAPI.Framework.ContentManagers
{
using FileStream stream = File.OpenRead(file.FullName);
using SKBitmap bitmap = SKBitmap.Decode(stream);
if (bitmap is null)
throw new InvalidDataException($"Failed to load {file.FullName}. This doesn't seem to be a valid PNG image.");
rawPixels = SKPMColor.PreMultiply(bitmap.Pixels);
width = bitmap.Width;
height = bitmap.Height;