getTextSizeAsync function

Future<(Size, int)> getTextSizeAsync(
  1. String text,
  2. int fontFace,
  3. double fontScale,
  4. int thickness,
)

GetTextSizeWithBaseline calculates the width and height of a text string including the basline of the text. It returns an image.Point with the size required to draw text using a specific font face, scale, and thickness as well as its baseline.

For further details, please see: http:///docs.opencv.org/master/d6/d6e/group__imgproc__draw.html#ga3d2abfcb995fd2db908c8288199dba82

Implementation

Future<(Size size, int baseline)> getTextSizeAsync(
  String text,
  int fontFace,
  double fontScale,
  int thickness,
) async {
  final ctext = text.toNativeUtf8().cast<ffi.Char>();
  final ret = cvRunAsync2<(Size, int)>(
      (callback) => cffi.GetTextSizeWithBaseline_Async(ctext, fontFace, fontScale, thickness, callback),
      (completer, p, p1) {
    final size = Size.fromPointer(p.cast<cvg.Size>());
    final baseline = p1.cast<ffi.Int>().value;
    calloc.free(p1);
    completer.complete((size, baseline));
  });
  calloc.free(ctext);
  return ret;
}