downscaleTo method

double downscaleTo(
  1. Image dstImage,
  2. int maxSize
)

Downscales the image so that its maximum dimension equals the given maximum size, while preserving the aspect ratio. Note: If the maximum dimension is already smaller than the given maximum size, the function does nothing and the returned scale ratio is 1.

param dstImage Destination image. param maxSize Maximum image size, in pixels. The value must be greater than 0. return The scaling ratio applied to the image. Range is )0:1). throws FaceException An error has occurred during Face Library execution.

Implementation

double downscaleTo(Image dstImage, int maxSize) {
  Pointer<Float> pScaleRatio = calloc();
  try {
    var err = faceSDK.id3FaceImage_DownscaleTo(_pHandle.value, dstImage.handle, maxSize, pScaleRatio);
    if (err != FaceError.success.value) {
      throw FaceException(err);
    }
    final vScaleRatio = pScaleRatio.value;
    return vScaleRatio;
  } finally {
    calloc.free(pScaleRatio);
  }
}