PlotDirector/PlotLine/Services/StoryElementReferenceStorage.cs
2026-12-05 17:22:38 +00:00

21 lines
631 B
C#

namespace PlotLine.Services;
public static class StoryElementReferenceStorage
{
public const string Folder = "story-element-references";
public static bool ValidBackupImage(byte[] bytes)
{
if (bytes.Length < 12 || bytes.Length > MapReferenceImageService.MaxStoredBytes ||
!bytes.AsSpan(0, 4).SequenceEqual("RIFF"u8) || !bytes.AsSpan(8, 4).SequenceEqual("WEBP"u8))
return false;
try
{
RasterImageValidation.Inspect(bytes, MapReferenceImageService.MaxPixels);
return true;
}
catch (InvalidDataException) { return false; }
}
}