fillPoly function

void fillPoly(
  1. VARP img,
  2. List<List<Point>> pts,
  3. Scalar color, {
  4. int lineType = LINE_8,
  5. int shift = 0,
  6. (double, double) offset = (0, 0),
})

Implementation

void fillPoly(
  VARP img,
  List<List<Point>> pts,
  Scalar color, {
  int lineType = LINE_8,
  int shift = 0,
  (double, double) offset = const (0, 0),
}) {
  final pPts = malloc<ffi.Pointer<c.mnn_cv_point_t>>(pts.length);
  final pInnerLength = malloc<ffi.Int32>(pts.length);
  pInnerLength.asTypedList(pts.length).setAll(0, pts.map((e) => e.length));
  for (int i = 0; i < pts.length; i++) {
    final pContour = malloc<c.mnn_cv_point_t>(pts[i].length);
    for (int j = 0; j < pts[i].length; j++) {
      pContour[j] = pts[i][j].ref;
    }
    pPts[i] = pContour;
  }
  final cOffset = Point.fromTuple(offset);
  c.mnn_cv_fillPoly(img.ptr, pPts, pInnerLength.cast(), pts.length, color.ref, lineType, shift, cOffset.ref);
  for (int i = 0; i < pts.length; i++) {
    malloc.free(pPts[i]);
  }
  malloc.free(pPts);
  malloc.free(pInnerLength);
  cOffset.dispose();
}