Skip to content

Commit

Permalink
ImageDeserializer - Add size and null check
Browse files Browse the repository at this point in the history
  • Loading branch information
NessieHax committed Jul 3, 2024
1 parent fedfc68 commit 60f569e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions PCK-Studio/Internal/Deserializer/ImageDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ namespace PckStudio.Internal.Deserializer
internal sealed class ImageDeserializer : IPckAssetDeserializer<Image>
{
public static readonly ImageDeserializer DefaultDeserializer = new ImageDeserializer();
// TODO: replace empty image with image displaying something went wrong
private static Image EmptyImage = new Bitmap(1, 1, PixelFormat.Format32bppArgb);

public Image Deserialize(PckAsset asset)
{
_ = asset ?? throw new ArgumentNullException(nameof(asset));
if (asset.Size == 0)
return EmptyImage;

using var stream = new MemoryStream(asset.Data);
try
{
Expand Down

0 comments on commit 60f569e

Please sign in to comment.