detectEquirectImageFormat function Assets and loading
Detects the EquirectImageFormat of bytes from its magic number.
Implementation
EquirectImageFormat detectEquirectImageFormat(Uint8List bytes) {
// Radiance files start with "#?" (e.g. "#?RADIANCE" or "#?RGBE").
if (bytes.length >= 2 && bytes[0] == 0x23 && bytes[1] == 0x3f) {
return EquirectImageFormat.radianceHdr;
}
// The OpenEXR magic number 20000630, little-endian (0x76 0x2f 0x31 0x01).
if (bytes.length >= 4 &&
bytes[0] == 0x76 &&
bytes[1] == 0x2f &&
bytes[2] == 0x31 &&
bytes[3] == 0x01) {
return EquirectImageFormat.openExr;
}
return EquirectImageFormat.ldr;
}