fromFile static method

Image fromFile(
  1. String? filepath,
  2. PixelFormat pixelFormat
)

Creates an Image from the specified file.

param filepath A string that contains the name of the file from which to create the Image. param pixelFormat The pixel format into which to convert the input image. return The newly created image. throws FaceException An error has occurred during Face Library execution.

Implementation

static Image fromFile(String? filepath, PixelFormat pixelFormat) {
  Image image = Image();
  Pointer<Char>? pFilepath = filepath?.toNativeUtf8().cast<Char>();
  try {
    var err = faceSDK.id3FaceImage_FromFile(image.handle, pFilepath ?? nullptr, pixelFormat.value);
    if (err != FaceError.success.value) {
      image.dispose();
      throw FaceException(err);
    }
    return image;
  } finally {
    if (pFilepath != null) {
      calloc.free(pFilepath);
    }
  }
}