getRegionAverage static method

Color getRegionAverage(
  1. Uint8List bytes, {
  2. String region = 'center',
  3. int step = 10,
})

Implementation

static Color getRegionAverage(Uint8List bytes, {String region = 'center', int step = 10}) {
  final image = img.decodeImage(bytes);
  if (image == null) {
    return Colors.white;
  }

  int startY;
  int endY;

  if (region == 'top') {
    startY = 0;
    endY = image.height ~/ 3;
  } else if (region == 'bottom') {
    startY = image.height * 2 ~/ 3;
    endY = image.height;
  } else {
    startY = image.height ~/ 3;
    endY = image.height * 2 ~/ 3;
  }

  return regionAverage(image, startY, endY, step: step);
}