unwrap method

AnalysisImage unwrap()

Implementation

AnalysisImage unwrap() {
  switch (format) {
    case AnalysisImageFormat.yuv_420:
      return Yuv420Image(
        height: height,
        width: width,
        cropRect: Rect.fromLTWH(
          cropRect!.left.toDouble(),
          cropRect!.top.toDouble(),
          cropRect!.width.toDouble(),
          cropRect!.height.toDouble(),
        ),
        planes: planes!.map((p) => p!.unwrap()).toList(),
        format: InputAnalysisImageFormat.values.byName(format.name),
        rotation: InputAnalysisImageRotation.values.byName(rotation!.name),
      );
    case AnalysisImageFormat.bgra8888:
      return Bgra8888Image(
        height: height,
        width: width,
        planes: planes!.map((p) => p!.unwrap()).toList(),
        format: InputAnalysisImageFormat.values.byName(format.name),
        rotation: InputAnalysisImageRotation.values.byName(rotation!.name),
      );
    case AnalysisImageFormat.jpeg:
      return JpegImage(
        height: height,
        width: width,
        bytes: bytes!,
        cropRect: cropRect != null
            ? Rect.fromLTWH(
                cropRect!.left.toDouble(),
                cropRect!.top.toDouble(),
                cropRect!.width.toDouble(),
                cropRect!.height.toDouble(),
              )
            : null,
        format: InputAnalysisImageFormat.values.byName(format.name),
        rotation: InputAnalysisImageRotation.values.byName(rotation!.name),
      );
    case AnalysisImageFormat.nv21:
      return Nv21Image(
        height: height,
        width: width,
        bytes: bytes!,
        planes: planes!.map((p) => p!.unwrap()).toList(),
        cropRect: Rect.fromLTWH(
          cropRect!.left.toDouble(),
          cropRect!.top.toDouble(),
          cropRect!.width.toDouble(),
          cropRect!.height.toDouble(),
        ),
        format: InputAnalysisImageFormat.values.byName(format.name),
        rotation: InputAnalysisImageRotation.values.byName(rotation!.name),
      );
    case AnalysisImageFormat.unknown:
      throw "Unhandled format: $format";
  }
}