processBytes method

Future<ScanResult> processBytes(
  1. Uint8List bytes,
  2. ScanMode mode, {
  3. int width = 640,
  4. int height = 480,
})

Processes raw byte buffer directly from memory.

Implementation

Future<ScanResult> processBytes(
  Uint8List bytes,
  ScanMode mode, {
  int width = 640,
  int height = 480,
}) async {
  initialize();
  try {
    final inputImage = InputImage.fromBytes(
      bytes: bytes,
      metadata: InputImageMetadata(
        size: Size(width.toDouble(), height.toDouble()),
        rotation: InputImageRotation.rotation0deg,
        format: InputImageFormat.nv21,
        bytesPerRow: width,
      ),
    );
    return await processInputImage(inputImage, mode);
  } catch (e) {
    return ScanResult.error(
      mode,
      'Failed to process raw bytes: ${e.toString()}',
    );
  }
}