Skip to content

Instantly share code, notes, and snippets.

@R00tkitSMM
Created October 31, 2024 10:52
Show Gist options
  • Save R00tkitSMM/8c7ddebc9c903f5f54a0d6a5774dc79e to your computer and use it in GitHub Desktop.
Save R00tkitSMM/8c7ddebc9c903f5f54a0d6a5774dc79e to your computer and use it in GitHub Desktop.
filter out other file formats
bool isKTX2Header(const uint8_t *buffer, size_t size) {
const uint8_t ktx2Identifier[12] = {0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32,
0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A};
if (size < 12) {
return false; // Buffer is too small to be a KTX2 header
}
// Compare the first 12 bytes of the buffer with the KTX2 identifier
return memcmp(buffer, ktx2Identifier, 12) == 0;
}
bool isEXRHeader(const uint8_t* buffer, size_t size) {
const uint8_t exrMagicNumber[4] = {0x76, 0x2F, 0x31, 0x01};
if (size < 4) {
return false; // Buffer is too small to be an EXR header
}
// Compare the first 4 bytes of the buffer with the EXR magic number
return memcmp(buffer, exrMagicNumber, 4) == 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment