Adds an error message for an invaild png

This commit is contained in:
atravita-mods 2022-08-05 17:21:53 -04:00 committed by GitHub
parent ab34b6142d
commit 7a3b0e180f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -254,6 +254,8 @@ namespace StardewModdingAPI.Framework.ContentManagers
{ {
using FileStream stream = File.OpenRead(file.FullName); using FileStream stream = File.OpenRead(file.FullName);
using SKBitmap bitmap = SKBitmap.Decode(stream); using SKBitmap bitmap = SKBitmap.Decode(stream);
if (bitmap is null)
throw new InvalidDataException("{file.FullName} appears not to be a valid image file.");
rawPixels = SKPMColor.PreMultiply(bitmap.Pixels); rawPixels = SKPMColor.PreMultiply(bitmap.Pixels);
width = bitmap.Width; width = bitmap.Width;
height = bitmap.Height; height = bitmap.Height;