Mat.create constructor

Mat.create({
  1. int rows = 0,
  2. int cols = 0,
  3. int r = 0,
  4. int g = 0,
  5. int b = 0,
  6. MatType? type,
})

Implementation

factory Mat.create({int rows = 0, int cols = 0, int r = 0, int g = 0, int b = 0, MatType? type}) {
  if (rows == 0 && cols == 0) {
    return Mat.empty();
  } else {
    type ??= MatType.CV_8UC3;
    final scalar = Scalar(b.toDouble(), g.toDouble(), r.toDouble(), 0);
    return Mat._create(
      rows * cols * type.elemSize,
      (p) => ccore.cv_Mat_create_5(scalar.ref, rows, cols, type!.value, p, ffi.nullptr),
    );
  }
}