isValidFile method

  1. @override
bool isValidFile(
  1. Uint8List data
)
inherited

Is the given file a valid BMP image?

Implementation

@override
bool isValidFile(Uint8List data) {
  if (!BmpFileHeader.isValidFile(InputBuffer(data)) || data.length < 18) {
    return false;
  }
  // Validate the DIB header size to avoid misdetecting non-BMP files that
  // merely start with the 'BM' signature.
  final dibHeaderSize = (InputBuffer(data)..skip(14)).readUint32();
  return dibHeaderSize >= 12 && dibHeaderSize <= 124;
}