21 lines
631 B
C#
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; }
|
|
}
|
|
}
|