isImageFile static method
PNG, JPEG oder WebP am Dateikopf — nur solche Dateien werden abgelegt und von der Platte uebernommen.
Implementation
@visibleForTesting
static bool isImageFile(Uint8List b) {
bool beginntMit(List<int> kopf, [int ab = 0]) {
if (b.length < ab + kopf.length) return false;
for (var i = 0; i < kopf.length; i++) {
if (b[ab + i] != kopf[i]) return false;
}
return true;
}
return beginntMit(const [0x89, 0x50, 0x4E, 0x47]) ||
beginntMit(const [0xFF, 0xD8, 0xFF]) ||
(beginntMit(const [0x52, 0x49, 0x46, 0x46]) && beginntMit(const [0x57, 0x45, 0x42, 0x50], 8));
}