exportFrames method

Future<List<RawFrame>?> exportFrames()

Implementation

Future<List<RawFrame>?> exportFrames() async {
  if (_frames.isEmpty) {
    return null;
  }
  final bytesImages = <RawFrame>[];
  for (final frame in _frames) {
    final bytesImage =
        await frame.image.toByteData(format: ui.ImageByteFormat.png);

    if (frame.image.width >= _maxWidthFrame) {
      _maxWidthFrame = frame.image.width;
    }

    if (frame.image.height >= _maxHeightFrame) {
      _maxHeightFrame = frame.image.height;
    }

    if (bytesImage != null) {
      bytesImages.add(RawFrame(16, bytesImage));
    } else {
      debugPrint('Skipped frame while enconding');
    }
  }
  return bytesImages;
}