Add PNG file type

This commit is contained in:
jvyden 2021-11-13 06:24:17 -05:00
commit 322c043a51
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 5 additions and 2 deletions

View file

@ -27,6 +27,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
LbpFileType.Voice => true,
LbpFileType.Plan => true,
LbpFileType.Jpeg => true,
LbpFileType.Png => true,
#if DEBUG
_ => throw new ArgumentOutOfRangeException(nameof(file), $"Unhandled file type ({file.FileType}) in FileHelper.IsFileSafe()"),
#else
@ -66,10 +67,11 @@ namespace LBPUnion.ProjectLighthouse.Helpers
{
reader.BaseStream.Position = 0;
// Determine if file is JPEG
// Determine if file is JPEG/PNG
byte[] header = reader.ReadBytes(9);
if (header[0] == 0xFF && header[1] == 0xD8 && header[2] == 0xFF && header[3] == 0xE0) return LbpFileType.Jpeg;
if (header[0] == 0x89 && header[1] == 0x50 && header[2] == 0x4E && header[3] == 0x47) return LbpFileType.Png;
return LbpFileType.Unknown; // Still unknown.
}

View file

@ -9,7 +9,8 @@ namespace LBPUnion.ProjectLighthouse.Types.Files
Plan, // PLN, uploaded with levels
Voice, // VOP, voice data
Painting, // PTG, paintings
Jpeg, // JFIF / FIF, used in sticker switches
Jpeg, // JFIF / FIF, used in sticker switches,
Png, // used in LBP Vita
Unknown,
}
}